Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I want to be able to count the number of parts in an assembly that have a certain custom iproperty value, i.e. I want to count the number of parts with an "Infill" iproperty that have the value of "I". I have the code below so far but it it not counting correctly. Any help is much appreciated.
'Define assembly Dim asmDoc As AssemblyDocument asmDoc = ThisApplication.ActiveDocument 'Define assembly Component Definition Dim oAsmCompDef As AssemblyComponentDefinition oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition 'Selected components collection Dim oSelected As ObjectCollection oSelected = ThisApplication.TransientObjects.CreateObjectCollection Dim iQty As Integer 'Add to Object Collection For iQty = 1 To asmDoc.SelectSet.Count If TypeOf asmDoc.SelectSet.Item(iQty) Is ComponentOccurrence Then oSelected.Add(asmDoc.SelectSet.Item(iQty)) End If Next Dim Occ As ComponentOccurrence If oSelected.Count >= 1 Then For iQty = 1 To oSelected.Count Occ = oSelected.Item(iQty) 'Infill iProperty Dim propertyName1 As String = "Infill" Dim propertyValue1 As String = "I" customPropertySet = Occ.Definition.Document.PropertySets.Item("Inventor User Defined Properties") Try prop = customPropertySet.Item(propertyName1) prop.Value = propertyValue1 Catch 'Assume error means not found customPropertySet.Add("", propertyName1) prop = customPropertySet.Item(propertyName1) prop.Value = propertyValue1 End Try Next End If
Solved! Go to Solution.