Hi,
I would like to be able to select a part/sub-assembly in the assembly environent and then run a rule which displays an iproperty from the selected part/sub-assembly.
It's driving me crazy
Thanks for any help
Solved! Go to Solution.
Solved by LukeDavenport. Go to Solution.
This is the code I am using. Everything works except for the last part. Even though I (think) I'm asking for the iproperties of the selected item I only get the iproperties of the top level assembly
SyntaxEditor Code Snippet
Dim oOccurrence As ComponentOccurrence Try oOccurrence = ThisDoc.Document.SelectSet.Item(1) Catch MessageBox.Show("Please select a component before running this rule.", "iLogic") Return End Try Dim doc As Document Dim Prop As String 'Set the selected item oOccurrence = ThisApplication.ActiveDocument.SelectSet.Item(1) 'get the selected item document occurrence name doc = oOccurrence.Definition.Document 'get the property'Prop = iProperties.Value(doc:1, "Custom", "Stroke") Prop = iProperties.Value(doc, "Project", "Part Number") 'Dispaly Property in Msg Box MessageBox.Show(Prop)
Hi David,
I think this'll work. We need to refer to the occurrence name, and also be aware that if you have selected an occurrence in a sub-component, then the object you have selected will actually be a 'componentoccurrenceproxy' object, that you need to find the native componentoccurrence from to use the iLogic iProperties line afterwards.
SyntaxEditor Code Snippet
Dim oOccurrence As ComponentOccurrence Dim Prop As String Try oOccurrence = ThisDoc.Document.SelectSet.Item(1) Catch MessageBox.Show("Please select a component before running this rule.", "iLogic") Return End Try If TypeOf oOccurrence Is ComponentOccurrenceProxy Then Prop = iProperties.Value(oOccurrence.NativeObject.Name, "Project", "Part Number") Else Prop = iProperties.Value(oOccurrence.Name, "Project", "Part Number") End If 'Display Property in Msg Box MessageBox.Show(Prop)