iLogic Properties Tool-Tip #3

This week’s post is a variation on a theme, hence the name. I’ve previously written about “Tool-Tips” with iLogic in Inventor (see posts below). The common theme is that the tool-tip will show iProperties for a part in the assembly (using a section filter). This version shows these properties at the tool-tip, as well as in Inventor’s status bar.

iProperty Tool-Tip with iLogic

IMPROVED: iProperty Tool-Tip with iLogic

Here’s a GIF of the new code in action:

Click me for High res version

This iteration of my code is probably the best version, as it does not use a message box. In previous versions, you needed to specify whether the rule was internal or external (to keep repeating), I’ve removed this by using a “GoTo XXX:” which keeps the code looping until the user hits escape. I’ve also built in a highlight set (my colour is set to orange, see RGB at the bottom for more).

Here’s the iLogic code:

'Code by @ClintBrown3D
'Originally posted at https://clintbrown.co.uk/ilogic-properties-tool-tip-3
'This is an updated of the code found here: https://clintbrown.co.uk/iproperty-tool-tip-with-ilogic-updated
TheStart:
On Error GoTo ClintBrown3D

Dim doc = ThisApplication.ActiveDocument
Dim entity = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, "Select a Part 🙂 - or ESC to exit")

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")
	
	'--------------Show File Name in oFive if Description iProp is empty---------------
	If iProperties.Value(entity.Name, "Project", "Description") = "" Then : oFive = "Description: " & entity.Name : End If

  Dim oSet1 As HighlightSet  ' Create a highlight set.
  oSet1 = doc.CreateHighlightSet
  oSet1.Color = ThisApplication.TransientObjects.CreateColor(255, 125, 0) ' Change the color
  Call oSet1.AddItem(entity)

bob = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAssemblyLeafOccurrenceFilter, (oOne & " - " & oTwo & " - "  & oThree & " - "  & oFour & " - "  & oFive))
bob = ""
Call oSet1.Clear
End If

If (Not entity Is Nothing) Then  'Allow Escape to Exit 

GoTo TheStart:
End If

Return 
ClintBrown3D:

Admittedly I have not heavily commented the code, but if you click through to the first link shared, there are a few more insights that can be found there.

RGB: Put simply, this is the system that Inventor uses for colours. What might be useful though, is a link to common colours as RGB, check out https://en.wikipedia.org/wiki/RGB_color_model

In the code, you will see a reference to the highlight colour, you could for instance match the highlight to your corporate colour, or something similar.

oSet1.Color = ThisApplication.TransientObjects.CreateColor(255, 125, 0) ' Change the color