Adding custom iProperties with Array List

Adding custom iProperties with Array List

m.verbunt
Advocate Advocate
511 Views
2 Replies
Message 1 of 3

Adding custom iProperties with Array List

m.verbunt
Advocate
Advocate

Hi all,

 

I need some help to get this code to work. It was originally created to delete iProperties, but I want to add them instead. The rule runs, but no iPropeties are created.

 

I would like to understand how I can get line 21 to works.

 

What I want this rule to do:

Check if the Custom iProperty (Found in the Array List) exists, if so, leave it alone, if not create it.

 

I can get this all to work by creating a "separate" rule for each iProperty, but the code gets to long and complicated. But doing it this way, by using an Array list, it keeps the code nice and clean. And it will make it easier to add or remove custom iProperties down the line.

 

Any help would be greatly appreciated!

 

' Set of Required iProperties
Dim MyArrayList As New ArrayList
MyArrayList.Add("AssyMat")
MyArrayList.Add("AutoCAD tek")
MyArrayList.Add("BomStructure")
MyArrayList.Add("Nav_Code")
MyArrayList.Add("Nav_Description")
MyArrayList.Add("Verdor Code")
MyArrayList.Add("Coating")


'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 MyArrayList.Contains(oCustProp.name)Then
'skip it
Else
'add the custom iProperty
oCustProp.Add
End If
Next
0 Likes
Accepted solutions (1)
512 Views
2 Replies
Replies (2)
Message 2 of 3

marcin_otręba
Advisor
Advisor
Accepted solution

hi,

 

try:

 

    ' Set of Required iProperties
Dim MyArrayList As New ArrayList
MyArrayList.Add ("AssyMat")
MyArrayList.Add ("AutoCAD tek")
MyArrayList.Add ("BomStructure")
MyArrayList.Add ("Nav_Code")
MyArrayList.Add ("Nav_Description")
MyArrayList.Add ("Verdor Code")
MyArrayList.Add ("Coating")
oCustomPropertySet = ThisDoc.Document.PropertySets.Item("Inventor User Defined Properties")
For i = 0 To MyArrayList.Count-1
    Try
        oCustomPropertySet.Add("",myarraylist(i))
        Catch
            
        End Try
Next


Hi, maybe you want to vote my:

Ideas

or check my apps:

DrawingTools   View&ColoringTools   MRUFolders

0 Likes
Message 3 of 3

m.verbunt
Advocate
Advocate

Hi Marcin,

 

Thank you so much for helping me out! This piece of code works like a charm and is even cleaner then the one I had come up with. Awsome!

 

Thanks!

0 Likes