I found some code on a forum showing how to handle mouse events in iLogic. Using the mouse selection code, I decided to write a bit of iLogic to show iProperties, for parts selected in an Assembly file.
In the code, I have set the selection filter to “Part”, the default is “Component”, this means that a user is able to select a part file in an assembly, regardless of it’s position in a sub assembly. This can be set back to “Component” in the code by setting the selection filter as shown below.
The animated GIF shows the code in action, note I am using an iTrigger to fire the rule:
Here’s the code:
'Code by @ClintBrown3D 'Originally posted at https://clintbrown.co.uk/iproperty-tool-tip-with-ilogic 'Mouse input code based on this forum post: https://forums.autodesk.com/t5/inventor-customization/ilogic-to-handle-mouse-event-for-part-selection/td-p/3902918 Dim doc = ThisApplication.ActiveDocument Dim entity = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, "Select a Part :)") If (Not entity Is Nothing) Then oOne = "Part Number : " & iProperties.Value(entity.Name, "Project", "Part Number") oTwo = "Mass : " & Round(iProperties.MassOfComponent(entity.Name), 2) & " kg" oThree = "Material : " & iProperties.MaterialOfComponent(entity.Name) oFour = "Designer : " & iProperties.Value(entity.Name, "Project", "Designer") 'oFive = "Description : " & iProperties.Value(entity.Name, "Project", "Description") MessageBox.Show(oOne & vbLf & oTwo & vbLf & oThree & vbLf & oFour & vbLf & oFive, entity.Name & " @ClintBrown3D") InventorVb.DocumentUpdate(False) End If