Set Random Face Colours With iLogic

@ClintBrown3D Autodesk Inventor 07.png

This blog post is a direct result of a discussion on Twitter! the request was to automatically assign a random colour to a face in an Inventor part.

I wrote a little bit of code, loosely based my previous blog post, looking at generating random numbers to create colours. This specific code simply assigns a random appearance to a face in Inventor, the code keeps running until the user hits “Escape”, the tool-tip explains this to the user.

You can set all of the faces back to default by using the code in this blog post.

The animated GIF below shows the utility in action.

Random Face colours.gif

The iLogic code is available below. Make sure to change “RULENAME” below to match the name of your rule, this allows the rule to keep running, until you hit escape.

'Code by @ClintBrown3D, originally posted at
On Error GoTo ClintBrown3D
Dim doc = ThisApplication.ActiveDocument
Dim entity = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select a Face, ESC to Cancel")

RANDOMISER = Round(Rnd * 750)
'RANDOMISER = "Default"

oStyle = doc.RenderStyles.Item(RANDOMISER) 
entity.SetRenderStyle(kOverrideRenderStyle, oStyle)



Comments are closed.

Create a website or blog at

Up ↑

%d bloggers like this: