Hi c.rp.Henderson,
As written, I don't see a need for the 2 lists, so I think you can use one list and an 'Else If' to resolve this as in this 1st version:
'define list of custom properties
Dim MyArrayList As New ArrayList
MyArrayList.add("STEEL")
MyArrayList.add("PAINT")
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
'Iterate through all of the occurrences
Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oAsmCompDef.Occurrences.AllReferencedOccurrences(oAsmCompDef)
'define custom property collection
oCustomPropertySet = oOccurrence.Definition.Document.PropertySets.Item("Inventor User Defined Properties")
'look at each property in the collection
For Each oCustProp In oCustomPropertySet
'check property name against the list
If MyArrayList.Contains(oCustProp.Name) Then
MessageBox.Show(oOccurrence.ReferencedFileDescriptor.FullFileName & " contains STEEL operations, which will be deleted.", "STEEL Operations")
'delete the custom iProperty
oCustProp.Delete
MsgBox(oCustProp.Name & " was deleted")
'Going to add a line here to add a replacement iProp
'check property name against the list
Else If MyArrayList.Contains(oCustProp.Name) Then
MessageBox.Show(oOccurrence.ReferencedFileDescriptor.FullFileName & " contains PAINT operations, which will be deleted.", "PAINT Operations")
'delete the custom iProperty
oCustProp.Delete
MsgBox(oCustProp.Name & " was deleted")
'Going to add a line here to add a replacement iProp
End If
Next
Next
If the 2 lists are required, then you can add a 'Continue For' line to move on once the first If/Then has executed. I think the error you're getting is because the property is deleted, and then 2nd If/Then condition is looking at that property still. The 'Continue For' should resolve this.
'define list of custom properties
Dim MyArrayList As New ArrayList
MyArrayList.add("STEEL")
'define list of custom properties
Dim MyArrayList1 As New ArrayList
MyArrayList1.add("PAINT")
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
'Iterate through all of the occurrences
Dim oOccurrence As ComponentOccurrence
For Each oOccurrence In oAsmCompDef.Occurrences.AllReferencedOccurrences(oAsmCompDef)
'define custom property collection
oCustomPropertySet = oOccurrence.Definition.Document.PropertySets.Item("Inventor User Defined Properties")
'look at each property in the collection
For Each oCustProp In oCustomPropertySet
'check property name against the list
If MyArrayList.Contains(oCustProp.Name) Then
MessageBox.Show(oOccurrence.ReferencedFileDescriptor.FullFileName & " contains STEEL operations, which will be deleted.", "STEEL Operations")
'delete the custom iProperty
oCustProp.Delete
MsgBox(oCustProp.Name & " was deleted")
'Going to add a line here to add a replacement iProp
Continue For
End If
'check property name against the list
If MyArrayList1.Contains(oCustProp.Name) Then
MessageBox.Show(oOccurrence.ReferencedFileDescriptor.FullFileName & " contains PAINT operations, which will be deleted.", "PAINT Operations")
'delete the custom iProperty
oCustProp.Delete
MsgBox(oCustProp.Name & " was deleted")
'Going to add a line here to add a replacement iProp
End If
Next
Next
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com