List Custom iProperties of selected occurrence

<?xml encoding=”UTF-8″>By Adam Nagy

As you can see in this blog post you can prompt the user to select an object using iLogic:
http://adndevblog.typepad.com/manufacturing/2013/11/do-selection-from-ilogic.html

Once you have the selected component then using the Inventor API you can also get all the iProperties from the document that is represented by that occurrence:
http://modthemachine.typepad.com/my_weblog/2010/02/accessing-iproperties.html

Here is an iLogic Rule that asks the user to select a component then lists its Custom iProperties: 

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(
"Inventor User Defined Properties")
Dim msg As String
For Each prop In propSet
msg = msg + prop.Name + " = " + _
prop.Value.ToString() + vbCrLf
Next
MessageBox.Show(msg, "iProperties")
End If

IProperties

 If you want to do things wihtout the user having to select a component then you could do it like this:

Dim msg As String
' If you know the name of both the component
' and the iProperties then you can do this
msg = "MyText = " +
iProperties.Value("TheBox:1", "Custom", "MyText")
MessageBox.Show(msg, "iProperties")
' If you only know the component name then
' first get the component
comp = Component.InventorComponent("TheBox:1")
' Then iterate through the Custom iProperties
Dim doc = comp.Definition.Document
Dim propSet = doc.propertySets(
"Inventor User Defined Properties")
msg = ""
For Each prop In propSet
msg = msg + prop.Name + " = " + _
prop.Value.ToString() + vbCrLf
Next
MessageBox.Show(msg, "iProperties")

Comments

3 responses to “List Custom iProperties of selected occurrence”

  1. New APP for Sheet metal & Automate CUSTOM iProperties for Autodesk Inventor.
    Now compatible from 2013 to 2017
    you can view data sheet & video at:
    https://apps.autodesk.com/INVNTOR/it/Detail/Index?id=appstore.exchange.autodesk.com:mc-cadinventortemplete:en

  2. Am I correct that this code does not work on CC parts like Structural beams?

  3. Sorry it does work, obviously it does not show user defined props.

Leave a Reply to matteoCancel reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading