Public VectorMode As Boolean Public counter As Long Private Sub SchiebenInXRichtung_Click() ' This procedure moves a component along a vector Dim SelectedObjects As New Collection Dim oOccurrence As ComponentOccurrence Dim oTransformation As Matrix Dim oTranslation As Vector Dim VectorToAdd As Vector Dim ProblemConstraint As AssemblyConstraint On Error GoTo 0 ThisApplication.TransactionManager.StartTransaction ThisApplication.ActiveDocument, "Verschiebung" For counter = 1 To ThisApplication.ActiveDocument.SelectSet.Count SelectedObjects.Add ThisApplication.ActiveDocument.SelectSet.Item(counter) Next For Each oOccurrence In SelectedObjects Set oTransformation = oOccurrence.Transformation Set oTranslation = oTransformation.Translation Set VectorToAdd = ThisApplication.TransientGeometry.CreateVector(VectorX / 10, 0, 0) ' Add the vector in the boxes to the translation vector of the component and update tranformation oTranslation.AddVector VectorToAdd oTransformation.SetTranslation oTranslation, False If oOccurrence.Constraints.Count > 0 Then If MsgBox("Component " & oOccurrence.Name & " has constraints. Remove them?", vbYesNo, "Constraint Problem") = vbYes Then For Each ProblemConstraint In oOccurrence.Constraints ProblemConstraint.Delete Next End If End If oOccurrence.SetTransformWithoutConstraints oTransformation Next ' For Each oOccurrence In SelectedObjects ' ThisApplication.ActiveDocument.SelectSet.Select oOccurrence ' Next Set SelectedObjects = Nothing ThisApplication.TransactionManager.EndTransaction End Sub Private Sub UserForm_Initialize() ' Initialize the forms settings Me.Top = GetSetting("Verschiebung", "Initialize", "Top", 0) Me.Left = GetSetting("Verschiebung", "Initialize", "Left", 0) End Sub Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer) SaveSetting "Verschiebung", "Initialize", "Top", Me.Top SaveSetting "Verschiebung", "Initialize", "Left", Me.Left End Sub