
Not applicable
โ04-15-2015
10:07 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I placed several bearings from Content Center and I want to place them on shafts with Insert constraint. I have the following rule that works:
SyntaxEditor Code Snippet
Dim oAssyDoc As AssemblyDocument oAssyDoc = ThisApplication.ActiveDocument Dim oOcc1 As ComponentOccurrence Dim oOcc2 As ComponentOccurrence Dim bearing_name As String=Parameter("category4")+":1" oOcc1 = Component.InventorComponent(bearing_name) oOcc2 = Component.InventorComponent("shaft1") Dim oPartDef1 As PartComponentDefinition oPartDef1 = oOcc1.Definition Dim oPartDef2 As PartComponentDefinition oPartDef2 = oOcc2.Definition Dim iMate1 As iMateDefinition iMate1 = oPartDef1.iMateDefinitions.Item(2) Dim iMate2 As iMateDefinition iMate2 = oPartDef2.iMateDefinitions.Item(8) Dim oEntity1 As Object Dim oEntity2 As Object Call oOcc1.CreateGeometryProxy(iMate1.Entity, oEntity1) Call oOcc2.CreateGeometryProxy(iMate2.Entity, oEntity2) Dim colCons As AssemblyConstraint colCons = oAssyDoc.ComponentDefinition.Constraints.AddInsertConstraint(oEntity1, oEntity2, 1, 0)
The problem is on this line
iMate1 = oPartDef1.iMateDefinitions.Item(2)
No2 reprezent the index number of the iMate constraint of the bearing from CC. (one of the insert constraints)
But sometimes the index number is different, 1 to 5.
I want to be able to define iMate1 as the name of the constraint "Insert In1" and not the index number. Somthing like this
iMate1 = oPartDef1.iMateDefinitions.name("Insert In1")
but is not working
Solved! Go to Solution.