Build more components in the assembly with iLogic

Build more components in the assembly with iLogic

Anonymous
Not applicable
344 Views
1 Reply
Message 1 of 2

Build more components in the assembly with iLogic

Anonymous
Not applicable

Hello,

 

I would like to build more components in one assembly with iLogic in the same time. I found a rule, but it is able built only one component in the assembly. I need build lots of components anywhere in the assembly.

 

 

' File path to use

oPath = "C:\Users\janos.buczko\Desktop\LUVE_ALL\30084924.ipt"

 

 

'[ Place component

Dim oAsmCompDef As AssemblyComponentDefinition

oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

Dim oTG As TransientGeometry = ThisApplication.TransientGeometry

Dim oMatrix As Matrix = oTG.CreateMatrix

Dim oOccurrence As ComponentOccurrence

 

'get user input

oX = InputBox("Enter the X co-ordinate, in inches.", "iLogic", "0")

oY = InputBox("Enter the Y co-ordinate, in inches.", "iLogic", "0")

 

'placement co-ordinates in cm's

oMatrix.SetTranslation(oTG.CreateVector(oX * 2.54, oY* 2.54, 0))

oOccurrence = oAsmCompDef.Occurrences.Add(oPath, oMatrix)

oOccurrence.Grounded = True

'zoom all

ThisApplication.ActiveView.Fit

 

Could anyone help me please?

 

Many thanks in advance

Janos

0 Likes
345 Views
1 Reply
Reply (1)
Message 2 of 2

perrysc
Enthusiast
Enthusiast

 

This should do it.

 

' File path to use
oPath = "C:\Users\janos.buczko\Desktop\LUVE_ALL\30084924.ipt"
 
 
'[ Place component
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
Dim oTG As TransientGeometry = ThisApplication.TransientGeometry
Dim oMatrix As Matrix = oTG.CreateMatrix
Dim oOccurrence As ComponentOccurrence
Dim oX As Double
Dim oY As Double
Dim oContinue As Boolean = True
Dim oResult As Integer
While oContinue = True 'get user input oX = InputBox("Enter the X co-ordinate, in inches.", "iLogic", "0") oY = InputBox("Enter the Y co-ordinate, in inches.", "iLogic", "0")   'placement co-ordinates in cm's oMatrix.SetTranslation(oTG.CreateVector(oX * 2.54, oY* 2.54, 0)) oOccurrence = oAsmCompDef.Occurrences.Add(oPath, oMatrix) oOccurrence.Grounded = True 'zoom all ThisApplication.ActiveView.Fit
oResult = MessageBox.Show("Do you wish to add another part?","Continue?",MessageBoxButtons.YesNo)
If oResult = vbYes Then
oContinue = True
Else
oContinue = False
End If
End While

 

0 Likes