Inventor iLogic: creating assembly by using imates with iLogic coding

Inventor iLogic: creating assembly by using imates with iLogic coding

Anonymous
Not applicable
1,200 Views
2 Replies
Message 1 of 3

Inventor iLogic: creating assembly by using imates with iLogic coding

Anonymous
Not applicable

Hello,

 

 I would like to create assembly by using iLogic codification. refer below code I used method to create an assembly - by using iMates constraint.

 

 The below code is worked well, but whenever I run the rule, assembly components occurred multiple times, which I would like to avoid.

can somebody give me solution to control the component occurrence in the assembly. I want only one time occurrence of each part in assembly.

there are total three parts in assembly.

 

Also I have attached jpg file for multiple component instance in assembly, while running rule each time with the below iLogic code. 

 

 Format:HTML Format Version:1.0 StartHTML: 165 EndHTML: 9445 StartFragment: 314 EndFragment: 9413 StartSelection: 314 EndSelection: 314SyntaxEditor Code Snippet

Public Sub Main()

Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
' Create a new matrix object. It will be initialized to an identity matrix.
Dim oMatrix As Matrix
oMatrix = ThisApplication.TransientGeometry.CreateMatrix
oMatrix.SetTranslation(ThisApplication.TransientGeometry.CreateVector(0,0,0))
' Place the first occurrence.
Dim oOcc1 As ComponentOccurrence
oOcc1 = oAsmCompDef.Occurrences.Add("C:\Data\GMS\OHH BSP iLogic Generator\Volute Casing\1.5x3x10-Case-OHH_E1204500533.ipt", oMatrix)
' Place the second occurrence, but use iMates for its placement. This is' equivalent to "Use iMate" check box on the "Place Component" dialog.
oMatrix.Cell(1, 4) = 1
Dim oOcc2 As ComponentOccurrence
oOccEnumerator = oAsmCompDef.Occurrences.AddUsingiMates("C:\Data\GMS\OHH BSP iLogic Generator\Casing Cover\04-Cover-OHH_E1204501642.ipt", False)
' Since the 'PlaceAllMatching' flag was specified as False, we can be' sure that just one ComponentOccurrence was returned in the enumerator.
Dim oOcc3 As ComponentOccurrence
oOccEnumerator1 = oAsmCompDef.Occurrences.AddUsingiMates("C:\Data\GMS\OHH BSP iLogic Generator\Bearing Housing\3C-OHH-Bearing.ipt", False)


' oOcc1 = oOccEnumerator.Item(1)
iLogicVb.UpdateWhenDone = True
End Sub


 

1,201 Views
2 Replies
Replies (2)
Message 2 of 3

martin.jacko
Autodesk
Autodesk

Hi,

 

What inventor version are you using?

 

Inventor 2019 ilogic contains Managed components, which should help you.

 

Martin

Message 3 of 3

dgreatice
Collaborator
Collaborator

Hi,

 

You Said:

 

"The below code is worked well, but whenever I run the rule, assembly components occurred multiple times, which I would like to avoid."

I think you must learn about iMate matching name first.

 

Example:

 

in Comp1, have 3 iMate

1. C1XY, matching to C2XY

2. C1XZ, matching to C2XZ

3. C1YZ, matching to C2YZ

 

so in Comp2, set iMate to:

1. C2XY, matching to C1XY

2. C2XZ, matching to C1XZ

3. C2YZ, matching to C1YZ

 

now in Comp3, set iMate to? Comp1 or Comp2?

 

Note: if 1 iMate in error or constrainst was no same type in another component imate, I will throw error, and will place multiple component.

Please use the ACCEPT AS SOLUTION or KUDOS button if my Idea helped you to solve the problem.

Autodesk Inventor Professional Certified 2014
0 Likes