SetObjectDisplayMode - all viewports

Relating to this recent thread, this is something I have been meaning to script for myself for awhile, so this gave me an excuse to do it. The following two Python scripts set one or more objects to one of the display modes available - but in all viewports simultaneously. There are two versions - the first one will give you a listbox with all the display modes available and ask you to chose, the second is a “fixed” version where the display mode is hard-coded and thus represents a one-click solution.

In the second case you will need to edit the script to put in the name of the display mode you want to activate (I put in the most common ones, you can change which lines are commented out). Make sure that the display mode is actually present and that the localized name is spelled correctly.

Apologies to the Mac people, the listbox version will not run yet, if I have time I will create a command box string-based version later. Current version now both Mac and Windows compatible, please re-download…! (thanks to Jeff Hammond for testing)

As usual, please report any bugs/failures and/or computer meltdowns :wink:

–Mitch (1.7 KB) (1.4 KB)

Edit #1: assigning Technical display mode or a variation of it to an object does not seem to be working, so beware. I guess this is because Technical has its own display pipeline - I see it is excluded from the normal SetObjectDisplayMode command as well… I revised the script to exclude these as well.

Edit #2: having unleashed this potentially poisonous tool, I had better also supply the antidote - a tool to remove any special display modes from a set of objects in all viewports… (782 Bytes)


Thanks Mitch for the useful example, no meltdown, but please allow extrusion objects to be selected !


Hey Clement -

Extrusions seem to work here - I tested… Running SR8?


Hi Mitch, i’ve not been aware that intType 1073741824 is explicitely required to pick extrusions, thanks :wink:

For the first script, i appreciate if it lets one choose idividual display modes but would suggest to get rid of Pen, Artistic and Technical as they do switch to Wireframe over here once applied (SR8).

To apply and remove SetObjectDisplayMode in all viewports should really make it into the built in command as an option.


rs.GetObjects includes extrusions as a part of type 8 or 16… There are other rs methods that don’t, though…

Done, re-download from above…

Script added until this is implemented as a real Rhino command, see above…


thanks Mitch ! Now i understand how to use “PipelineLocked”.


Me too… I just figured it out by looking at what the different display modes had under that attribute… :smile:


Hi Mitch!
Your script is great!
Can add to inside the script function to lock an object?
I would be very grateful if can implement this idea :blush:


I’m a little altered your script for locked objects. (1.4 KB)

Based on your script, I want to assign a color in all viewports for all meshes.
attribute objIDs = rs.SelMesh () does not work
Help please, if it will not be so hard :slight_smile: (1.3 KB)

To get all meshes in the file use:


To get only mesh objects that are visible and selectable, use


HTH, --Mitch

It really helped!
It works! Thanks :slight_smile:
How to combine two scripts into one python script?
Is this possible ??

The first script (626 Bytes)

and second script (1.1 KB)
In the execution of this script TRUE for locked meshes.
How to get rid of?

What code of Objects Type for unlocked meshes?

objIDs=rs.Unloced_meshes_only=rs.ObjectsByType (???)

When mixing the order of function standard arguments with keyword arguments, keyword names need to be assigned. Otherwise python function will “arrange” them as if they were all standard, so in this case “1” will become “True” for “select” argument, and default value of “0” will be used for “state”.

[quote=Helvetosaur]To get only mesh objects that are visible and selectable, use



# regular meshes (not hidden, not locked)

Thank you!
Its helped

Which function is responsible for Unlock selected objects?

Smething like this?

objects = rs.SelectedObjects()

Dosnt works
Message: list is not callable

You can use the ObjectsByType function to return locked objects id, and then unlock them:

# return the ids of locked meshes
objects = rs.ObjectsByType(32,state=2)
# unlock locked meshes
if len(objects)>0:
    un = rs.UnlockObjects(objects)
    print "there are no locked meshes"

Check the ObjectsByType function help file for more info.

How to write an identifier with such content ??

objects = rs.ObjectsByType (All unlocked objects except locked and unlocked meshes)

import rhinoscriptsyntax as rs

# all locked and unlocked objects. Hidden excluded
allObjs = rs.ObjectsByType(0, state=0)
excludeMeshes = []
for obj in allObjs:
    if not rs.IsMesh(obj):

If you want hidden objects included too, replace the upper line 4 with:

# all locked, unlocked and hidden objects
allObjs = rs.ObjectsByType(0, state=7)

Thanks for all!
I got what I wanted to achieve.
I was able to eliminate the script for locked and hidden objects.
I also managed to unite two scripts into one.
The only thing that does not work simulate _UnlockSelected command in python and insert it into this modified script
Here is script After _UnlockSelected .py (1.8 KB)

Please help :wink: