Code:
'define list of custom properties to keepDim MyArrayList As New ArrayList
MyArrayList.add("Abmessung")
MyArrayList.add("Baugruppen-Name")
MyArrayList.add("Bemerkung")
MyArrayList.add("Werkstoff")
'define custom property collection
oCustomPropertySet = ThisDoc.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 you don't want to delete
If Not MyArrayList.Contains(oCustProp.Name)Then
'skip it
'Else
'delete the custom iProperty
oCustProp.Delete
End If
Next
Dim propertyName1 As String = "Abmessung"
Dim propertyName2 As String = "Baugruppen-Name"
Dim propertyName3 As String = "Bemerkung"
Dim propertyName4 As String = "Werkstoff"
customPropertySet = ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties")
Try
prop = customPropertySet.Item(propertyName1)
prop = customPropertySet.Item(propertyName2)
prop = customPropertySet.Item(propertyName3)
prop = customPropertySet.Item(propertyName4)
Catch
' Assume error means not found
customPropertySet.Add("", propertyName1)
customPropertySet.Add("", propertyName2)
customPropertySet.Add("", propertyName3)
customPropertySet.Add("", propertyName4)
End Try