Message 1 of 2
iLogic skip iProperty feild when it does not exit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
ok I'm stumped...... What I am going for is to have Ilogic go out and sum my subassembly custom iproperties. The code that I have is able to go out and read the illogic if the iproperties exits but it gets an error when one of the subassemblies does not have the custom Iproperties. How do I change my code that if one of my subassemblies does not have custom iproperties, it will not error out?
SyntaxEditor Code Snippet
'- - - - - - - - - - - find or create custom iProperty - - - - - - - - - - Dim openDoc As Document openDoc = ThisDoc.Document Dim docFile As Document For Each docFile In openDoc.AllReferencedDocuments '--------------------------------------------------------------------------------- (Water Creation) Dim propertyName1 As String = "Water (PSI)" oCustomPropertySet = docFile.PropertySets.Item("Inventor User Defined Properties") Try oProp = oCustomPropertySet.Item(propertyName1) Catch oCustomPropertySet.Add(0, propertyName1) End Try Next '---------------------------------------------------------------------------------- (Voltage Creation) Dim propertyName3 As String = "Voltage" oCustomPropertySet = docFile.PropertySets.Item("Inventor User Defined Properties") Try oProp = oCustomPropertySet.Item(propertyName3) Catch oCustomPropertySet.Add(0, propertyName3) End Try '- - - - - - - - - - - Sum of the Custom iProperty - - - - - - - - - - iProperties.Value("Custom", "Water (PSI)") = 0 Dim oAsmCompDef As AssemblyComponentDefinition oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition Dim oOccurrence As ComponentOccurrence For Each oOccurrence In oAsmCompDef.Occurrences If Not TypeOf oOccurrence.Definition Is VirtualComponentDefinition Then xNumber = iProperties.Value("Custom", "Water (PSI)") yNumber = iProperties.Value(oOccurrence.Name,"Custom", "Water (PSI)") sumNumber = xNumber + yNumber iProperties.Value("Custom", "Water (PSI)") = sumNumber End If Next '---------------------------------------------------------------------- iProperties.Value("Custom", "Voltage") = 0 oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition For Each oOccurrence In oAsmCompDef.Occurrences If Not TypeOf oOccurrence.Definition Is VirtualComponentDefinition Then xNumber = iProperties.Value("Custom", "Voltage") yNumber = iProperties.Value(oOccurrence.Name,"Custom", "Voltage") sumNumber = xNumber + yNumber iProperties.Value("Custom", "Voltage") = sumNumber End If Next '-------------------------------------- Message Box Water = iProperties.Value("Custom", "Water (PSI)") Voltage = iProperties.Value("Custom", "Voltage") MessageBox.Show("Water = " & Water & vbLf & "Voltage = " & Voltage & vbLf, " Summary ")