Inventor 2015 – iLogic – Set colour of features based on name

Marketing
Marketing
  • Updated

By Luke Davenport 

Issue:

You’d like to colour features in your model by a rule – i.e. if the feature name contains “Hole” then make it red. 

Solution:

This is achieved by simply looping through all the part features, and assigning their colour. You can download the iLogic rule below and modify it to suit your purposes. Note that I’ve used a case insensitive check for the feature name, so the rule as downloaded will make a feature called “Hole123” red, and also a feature called “HOLE123”. You can of course chop and change to your heart’s content. 

Note when you are editing the code, the only lines you need to change are the lines shown below. At the moment the code is looking (case insensitive) for any features with “SLOT”, “POCKET” or “HOLE” in the feature name. Simply edit these lines as required, and copy and paste them to control the colour of more features. 

' Define new dictionary to hold colours required for each feature name

Dim oColourDict As New Dictionary(Of String, String)

' Add all your colour combinations in here, by copying existing lines

oColourDict.Add("SLOT", "Flaked Satin - Blue")

oColourDict.Add("POCKET", "Canary")

oColourDict.Add("Hole", "Red") 

And for any dodgy spellings in your colours, there’s a simple error check in the code to inform you that the colour ‘glavanized steel’ does not exist!

 

Download the code here

 

Was this article helpful?

0 out of 0 found this helpful

Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.