<?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
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")


Leave a Reply to Joris SteursCancel reply