Message 1 of 3

Not applicable
07-14-2020
06:17 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone,
First time poster and iLogic beginner so please be gentle 🙂
I am looking at adding the same part in an empty assembly via a form. The idea being that you input the number of parts you want and then click add they will be put nicely one on top of the other with an offset on the z axis. The offset will be hard coded and not part of the form.
I have managed to reach a point on which I can insert the number of parts I want but they are all on top of each other so I need help making them offset one to each other.
It seems that my z variable gets updated but it seems iLogic does not like it in the CreateVector function.
Code below:
Dim Counter As Integer = 0
While Counter < NumbersOfItemsToAdd
Counter = Counter + 1
oPath = ThisDoc.Path & "\"
oFile = "Generic Part.ipt"
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
Dim oTG As TransientGeometry
oTG = ThisApplication.TransientGeometry
Dim oMatrix As Matrix
oMatrix = oTG.CreateMatrix
Dim oOccurrence As ComponentOccurrence
oOccurence = oAsmCompDef.Occurrences.Add(oPath & oFile, oMatrix)
Dim Offset As Double
Offset = 10
Dim z As Double
z = Offset*Counter
oMatrix.SetTranslation(oTG.CreateVector(0,0,z))
oOccurence.Grounded = False
MessageBox.Show("Counter is " & Counter & vbCr & "Z is " & z, "Parameters")
End While
Solved! Go to Solution.