Inventor iLogic: creating assembly by using imates with iLogic coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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