• Blog posts


    By Luke Davenport 


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


    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