Message 1 of 8
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have code that will create custom iproperties for width, length, and thickness based on the range box of the parts in an assembly. The code is below. It works fine the first time the rule is run but errors when it is rule again after a change is made to the model. How do I get this to run after an update has been made to the model.
Thank you.
'Set a reference to the assembly component definition. 'This assumes an assembly document is open. Dim oAsmCompDef As AssemblyComponentDefinition oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition 'Conversion factor cm to in oCF = 0.393701 'Iterate through all of the occurrences Dim oOccurrence As ComponentOccurrence For Each oOccurrence In oAsmCompDef.Occurrences 'Check for and skip virtual components If Not TypeOf oOccurrence.Definition Is VirtualComponentDefinition Then oX = (oOccurrence.Definition.RangeBox.MaxPoint.X _ - oOccurrence.Definition.RangeBox.MinPoint.X)*oCF oY = (oOccurrence.Definition.RangeBox.MaxPoint.Y _ - oOccurrence.Definition.RangeBox.MinPoint.Y)*oCF oZ = (oOccurrence.Definition.RangeBox.MaxPoint.Z _ - oOccurrence.Definition.RangeBox.MinPoint.Z)*oCF 'Get middle number If oX > oY And oX < oZ Or oX > oZ And oX < oY Then oMiddle = oX GoTo Set_Width End If If oY > oX And oY < oZ Or oY > oZ And oY < oX Then oMiddle = oY GoTo Set_Width End If If oZ > oX And oZ < oY Or oZ > oY And oZ < oX Then oMiddle = oZ GoTo Set_Width End If 'Set Width Set_Width: iProperties.Value(oOccurrence.Name, "Custom", "Width") = Round(oMiddle,3) 'Set Length iProperties.Value(oOccurrence.Name, "Custom", "Length") = Round(MaxOfMany(oX, oY, oZ),3) 'Set Thickness iProperties.Value(oOccurrence.Name, "Custom", "Thickness") = Round(MinOfMany(oX, oY, oZ),3) End If Next
Solved! Go to Solution.