Popup with all Properties of selected component

Popup with all Properties of selected component

inventor4578
Advocate Advocate
754 Views
7 Replies
Message 1 of 8

Popup with all Properties of selected component

inventor4578
Advocate
Advocate

Hi,

I try to make a iLogic code to get all informations about selected component in 3D.

This is my code, but not working good for the moment....

Any idea ?

 

Thanks!

 

Dim entity = ThisApplication.CommandManager.Pick(
  SelectionFilterEnum.kAssemblyOccurrenceFilter, 
  "Select Component:")

If (Not entity Is Nothing) And _
(TypeOf entity Is ComponentOccurrence) Then
  Dim doc = entity.Definition.Document
  Dim propSet = doc.propertySets(
    "Summary Information")
  Dim msg As String
  For Each prop In propSet
    msg = msg + prop.Name + " = " + _
      prop.Value.ToString() + vbCrLf
  Next

    Dim propSet2 = doc.propertySets(
    "Document Summary Information")
  Dim msg2 As String
  For Each prop In propSet
    msg2 = msg2 + prop.Name + " = " + _
      prop.Value.ToString() + vbCrLf
  Next

     Dim propSet3 = doc.propertySets(
    "Design Tracking Properties")
  Dim msg3 As String
  For Each prop In propSet
    msg3 = msg3 + prop.Name + " = " + _
      prop.Value.ToString() + vbCrLf
  Next
  
       Dim propSet4 = doc.propertySets(
    "User Defined Properties")
  Dim msg4 As String
  For Each prop In propSet
    msg4 = msg4 + prop.Name + " = " + _
      prop.Value.ToString() + vbCrLf
  Next

    MessageBox.Show(msg + msg2 + msg3 + msg4, "iProperties")

End If

 

0 Likes
Accepted solutions (1)
755 Views
7 Replies
Replies (7)
Message 2 of 8

Michael.Navara
Advisor
Advisor

You can see my opensource project on GitHub. You can modify it for your needs.

https://github.com/CADstudioCZ/Autodesk-Inventor

 

0 Likes
Message 3 of 8

inventor4578
Advocate
Advocate

Thank for you reply.

I have 2017

0 Likes
Message 4 of 8

Michael.Navara
Advisor
Advisor

You can download the project, replace reference to 2017 API, modify displayed properties and compile it. For compiling you can use VS Community Edition (free for OpenSource projects). I hope the the code doesn't use anything special from 2018 API.

 

0 Likes
Message 5 of 8

inventor4578
Advocate
Advocate

I have to try, thank you!

0 Likes
Message 6 of 8

J-Camper
Advisor
Advisor

Using Property.Value fails on Thumbnails, Dates, and boolean properties when converting to string.  Try using Property.Expression like this:

Dim PickCO As ComponentOccurrence = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select Component")
If IsNothing(PickCO) Then Exit Sub ' If nothing gets selected then we're done

Dim PropertyMessage As String

For Each ps As PropertySet In PickCO.Definition.Document.PropertySets
	For Each prop As Inventor.Property In ps
		PropertyMessage += prop.Name & " = " & prop.Expression & vbCrLf
	Next
Next

MessageBox.Show(PropertyMessage, "Properties for " & PickCO.Name)

 

Let me know if you have any questions, or if this is not working as intended

 

0 Likes
Message 7 of 8

inventor4578
Advocate
Advocate

It is working good ! Thanks.

Is it possible to filter the results to see only the properties which has values? (and not see the properties which are empty)

 

Regards.

0 Likes
Message 8 of 8

J-Camper
Advisor
Advisor
Accepted solution

This would filter out blank properties:

 

Dim PickCO As ComponentOccurrence = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyOccurrenceFilter, "Select Component")
If IsNothing(PickCO) Then Exit Sub ' If nothing gets selected then we're done

Dim PropertyMessage As String

For Each ps As PropertySet In PickCO.Definition.Document.PropertySets
	For Each prop As Inventor.Property In ps
		If IsNothing(prop.Expression) Then Continue For
		PropertyMessage += prop.Name & " = " & prop.Expression & vbCrLf
	Next
Next

MessageBox.Show(PropertyMessage, "Properties for " & PickCO.Name)

Thumbnails and Part Icon come in as (NULL) and some properties may return 0's.  If you want those filtered out you need more filters.

 

Let me know if you have any questions, or if this is not working as intended.

0 Likes