Select objects by display color


I’m working with a CAD file that contains over 6K objects that I would like to subgroup according to their display colors. None of the objects have material colors applied, only display colors. Does anyone know of a way or have a script that can accomplish this? I looked at CV-Object Manager Tools but do not see this function in their toolset. Any advice/help would be appreciated.


Unfortunately, a script will not be possible. The required function to obtain the display color from an object is not available in the Python SDK (apparently). I have started a discussion thread over at the PluginCafe, regarding this.
However, a C++ plugin can be created to perform this action. But where a script would only need to be written once, a C++ plugin needs to be (well, maybe written once) compiled on pre-R20 Windows / macOS and again R20 Windows / macOS.
Meaning that it would require 4 project files to be set up for the same number of resulting plugin files, instead of a quick single one prototyped in Python.

What could be done via script is to look for the same Layer (color layer). But I guess that doesn’t help you in your particular situation.


As mentioned in the PluginCafé, you don’t need specific functions, you can go through the properties:

import c4d

def main():
    selectlist = doc.GetSelection() 
    for obj in selectlist: 
        print obj.GetName(), " ", obj[c4d.ID_BASEOBJECT_COLOR]
        obj[c4d.ID_BASEOBJECT_USECOLOR] = True
        obj[c4d.ID_BASEOBJECT_COLOR] = c4d.Vector(0,0,1)

if __name__=='__main__':

To write a selector, one would need to know how the selection criterion (the color) is supposed to be entered: a dialog with a color field? hardcoded in the script? RGB values in 8 or 16 bit? Vector range 0-1? By sampling an object?


Here, have a selector by sample:

import c4d
# Select an object with the desired display color set.
# The script will select all objects in the scene with the same display color.

def doToObject(obj, color):
    if obj[c4d.ID_BASEOBJECT_COLOR] == color:
        print "Object found: ", obj.GetName(), " color: ", color
        doc.SetSelection(obj, c4d.SELECTION_ADD)

def traverseTree(obj, color):
    if obj==None: return
    while obj != None:
        doToObject(obj, color)
        traverseTree(obj.GetDown(), color)
def main():
    selectlist = doc.GetActiveObjects(c4d.GETACTIVEOBJECTFLAGS_SELECTIONORDER)
    if len(selectlist) == 1:
        obj = selectlist[0]
        if obj:
            color = obj[c4d.ID_BASEOBJECT_COLOR]
            print "Search for color: ", color
            # maybe check obj[c4d.ID_BASEOBJECT_USECOLOR]
            root = doc.GetFirstObject()
            traverseTree(root, color)

if __name__=='__main__':

Note that the script does not check whether the display color is used, so if you have objects with the same display color but the “use display color” flag is not set, these get selected nevertheless.


Cairyn, thank you for your time and effort posting this script. It works perfectly and has saved me a lot of time.

Thank you again,


Hi @LonChaney. I’ve seen versions of this requested before, so I decided to write a couple scripts tonight:

You can get both of them for free from my dk-sandbox GitHub Repo.

Cairyn has already addressed your needs for this project, but perhaps this will prove useful to future folks dealing with similar CAD data.


Thank you Donovan, this work great! Adding all the objects to their own color coded null is an added bonus. Between this and the script from Cairyn I think I am ready for any CAD file thrown my way.