Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
JhoelForshav
in reply to: JhoelForshav

And I see now that you only wanted to input X,Y,Z once. Not for each occurrence.

Final code:grinning_squinting_face:

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()