Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I want to create a custom iProperty for parts that have an already defined custom iProperty called "Routing". Below is the code I have so far. Every time I run it I get an error message that says "Cannot find a property named "Routing." I know that there are parts in the assembly with the "Routing" property in them. Any suggestions would be appreciated.
Dim oAsmCompDef As AssemblyComponentDefinition oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition 'Conversion factor cm to in Dim oCF As Double = 0.393701 Dim oX As Double = 0 Dim oZ As Double = 0 'Iterate through all Of the occurrences Dim oOcc As ComponentOccurrence For Each oOcc In oAsmCompDef.Occurrences.AllReferencedOccurrences(oAsmCompDef) 'Check for infills and skip virtual components If iProperties.Value(oOcc.Name, "Custom", "Routing") = "_I" And Not TypeOf oOcc.Definition Is VirtualComponentDefinition Then oX = (oOcc.Definition.RangeBox.MaxPoint.X - oOcc.Definition.RangeBox.MinPoint.X)*oCF oZ = (oOcc.Definition.RangeBox.MaxPoint.Z - oOcc.Definition.RangeBox.MinPoint.Z) * oCF Try 'write to component iprops iProperties.Value(oOcc.Name, "Custom", "Width") = iProperties.Value("Custom", "Width") iProperties.Value(oOcc.Name, "Custom", "Height") = iProperties.Value("Custom", "Height") Catch 'catch errors 'create iprop with default value iProperties.Value("Custom", "Width") = Round(oZ, 3) iProperties.Value("Custom", "Height") = Round(oX, 3) 'write to component iprops iProperties.Value(oOcc.Name, "Custom", "Width") = iProperties.Value("Custom", "Width") iProperties.Value(oOcc.Name, "Custom", "Height") = iProperties.Value("Custom", "Height") End Try End If Next
Solved! Go to Solution.