06-03-2020
02:13 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
06-03-2020
02:13 AM
And I see now that you only wanted to input X,Y,Z once. Not for each occurrence.
Final code![]()
Dim oAsm As AssemblyDocument = ThisDoc.Document Dim oTG As TransientGeometry = ThisApplication.TransientGeometry Dim oUM As UnitsOfMeasure = ThisDoc.Document.UnitsOfMeasure Dim xyz As String = InputBox("Move component X,Y,Z", "Move this component", "0,0,0") Dim oX As Double = oUM.ConvertUnits(CDbl(xyz.Split(",")(0)), oUM.LengthUnits, UnitsTypeEnum.kDatabaseLengthUnits) Dim oY As Double = oUM.ConvertUnits(CDbl(xyz.Split(",")(1)), oUM.LengthUnits, UnitsTypeEnum.kDatabaseLengthUnits) Dim oZ As Double = oUM.ConvertUnits(CDbl(xyz.Split(",")(2)), oUM.LengthUnits, UnitsTypeEnum.kDatabaseLengthUnits) If oX + oY + oZ <> 0 For Each oComp As ComponentOccurrence In oAsm.ComponentDefinition.Occurrences Dim Grounded As Boolean = oComp.Grounded If Grounded = True Then oComp.Grounded = False Dim oVector As Vector = oTG.CreateVector(oX, oY, oZ) Dim oMatrix As Matrix = oComp.Transformation.Copy oVector.AddVector(oMatrix.Translation) oMatrix.SetTranslation(oVector, False) oComp.Transformation = oMatrix oComp.Grounded = Grounded Next End If InventorVb.DocumentUpdate()
Jhoel Forshav
Download my free Inventor Addin - Hole Projector
LinkedIn | Ideas | Contributions | Blog posts | Website