ilogic - list all custom properties

ilogic - list all custom properties

tegstette
Advocate Advocate
2,509 Views
7 Replies
Message 1 of 8

ilogic - list all custom properties

tegstette
Advocate
Advocate

HiSmiley Happy

 

Can someone help me out with a code that lists all custom properties for all instances in an entire structure?

I want to run the rule from the top assembly and get a list of all the custom properties used. Cannot find any similar rules for this...

 

Best regards
TG

Autodesk Inventor/Vault Professional 2021
0 Likes
Accepted solutions (1)
2,510 Views
7 Replies
Replies (7)
Message 2 of 8

Owner2229
Advisor
Advisor

Hi, try this code below. I suggest export it to an text file instead of showing in MsgBox, as the list might be a bit long.

 

Dim oDoc As Document = ThisApplication.ActiveDocument
Dim Docs As DocumentsEnumerator = oDoc.AllReferencedDocuments
Dim aDoc As Document
Dim Pros As New ArrayList
Dim item As String
For Each aDoc In Docs
    Dim oPropsets As PropertySets
    oPropsets = oDoc.PropertySets
    Dim oPropSet As PropertySet
    oPropSet = oPropsets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")
    Dim oPro As Inventor.Property
    For Each oPro In oPropSet
        Dim Found As Boolean = False
        For Each item In Pros
            If oPro.Name = item Then Found = True
        Next
        If Found = False Then
            Pros.Add(oPro.Name)
        End If
    Next
Next

Dim AllPros As String = "List of all used iProperties:"
For Each item In Pros
    AllPros = AllPros & vblf & item
Next
MsgBox(AllPros)

 

Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 3 of 8

tegstette
Advocate
Advocate

Hi

 

I tried the rule, but I get an error:

 

Invalid class string (Exception from HRESULT: 0x800401F3 (CO_E_CLASSSTRING))

 

more info:

System.Runtime.InteropServices.COMException (0x800401F3): Invalid class string (Exception from HRESULT: 0x800401F3 (CO_E_CLASSSTRING))

at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)

at Inventor.PropertySets.get_Item(Object Index)

at LmiRuleScript.Main()

at Autodesk.iLogic.Exec.AppDomExec.ExecRuleInAssembly(Assembly assem)

at iLogic.RuleEvalContainer.ExecRuleEval(String execRule)

 

 

Best regards
TG

Autodesk Inventor/Vault Professional 2021
0 Likes
Message 4 of 8

tegstette
Advocate
Advocate
Seems like there is something with this line:

oPropSet = oPropsets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF​9AE}")
Best regards
TG

Autodesk Inventor/Vault Professional 2021
0 Likes
Message 5 of 8

Owner2229
Advisor
Advisor
Accepted solution

Hi, it works for me with the Key reference, but you can try it like this:

Also, are you using iLogic, VBA or VB.Net?

 

Dim oDoc As Document = ThisApplication.ActiveDocument
Dim Docs As DocumentsEnumerator = oDoc.AllReferencedDocuments
Dim aDoc As Document
Dim Pros As New ArrayList
Dim item As String
For Each aDoc In Docs
    Dim oPropsets As PropertySets
    oPropsets = oDoc.PropertySets
    Dim oPropSet As PropertySet
    oPropSet = oPropsets.Item("Inventor User Defined Properties")
    Dim oPro As Inventor.Property
    For Each oPro In oPropSet
        Dim Found As Boolean = False
        For Each item In Pros
            If oPro.Name = item Then Found = True
        Next
        If Found = False Then
            Pros.Add(oPro.Name)
        End If
    Next
Next

Dim AllPros As String = "List of all used iProperties:"
For Each item In Pros
    AllPros = AllPros & vbLf & item
Next
MsgBox(AllPros)
Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
Message 6 of 8

tegstette
Advocate
Advocate

Thank youSmiley Happy

 

I use ilogic. The rule now lists all custom properties that has a value. But how do I get it to show all custom properties - also the empty ones...? I tried to alter the rule, but the inventor froze... so I guess what i tried was bad...:-)

Best regards
TG

Autodesk Inventor/Vault Professional 2021
0 Likes
Message 7 of 8

tegstette
Advocate
Advocate

Hi, again!

 

I figured it out, must have done something wrong the first time.

I just comment this line and it worked:

 

If oPro.Name = item Then Found = True

 

Thank you very much, works greatSmiley Happy

Best regards
TG

Autodesk Inventor/Vault Professional 2021
0 Likes
Message 8 of 8

tegstette
Advocate
Advocate

Hi

 

I was a little bit quick to accept this. I thought I had fiured it out, but when I study the result of my changes was not correct…

 

The rule now lists all custom properties that has a value. But how do I get it to show all custom properties - also the empty ones...?

 

Can you help me out again?

Best regards
TG

Autodesk Inventor/Vault Professional 2021
0 Likes