Bug: "Select by color" selects objects with different object colours in Rendered mode

I think that there is a bug in the the '_SelColor command. While in “Wireframe” of “Shaded” view, selecting an object with a certain colour and running that command will select any other visible non-locked object with the same object colour. However, when I repeat that in “Rendering” mode or some of my custom modes who show the rendering colour in the viewport, Rhino will select some other objects that have totally different object colour.

Hi Bobi - I guess that is as advertised -
“The SelColor command selects all objects of a specified display color or material diffuse color depending on the display mode of the active viewport.”

?

I think this does what you want (no color picker though)

import rhinoscriptsyntax as rs


def SelByObjectColor():
    
    ids = rs.GetObjects("Select objects", preselect=True)
    if not ids:return
    
    cols = list(set([rs.ObjectColor(id) for id in ids]))
    
    rs.EnableRedraw(False)
    
    for tempId in rs.NormalObjects():
        if rs.ObjectColor(tempId) in cols:
            rs.SelectObject(tempId)
            
    rs.EnableRedraw(True)
    
if __name__ == '__main__':SelByObjectColor()

@Rhino_Bulgaria - use this version - the above but saved to a .py file.

SelByObjectColor.py (462 Bytes)

To use the Python script use RunPythonScript, or a macro:

_-RunPythonScript "Full path to py file inside double-quotes"

-Pascal

1 Like

Wow, I didn’t knew that the '_SelColor command will ignore the object’s colour in some of the viewport modes and will select by material type instead. From my point of view, it’s a bit confusing and inconsistent that way, especially since I have plenty of custom modes and '_SelColor command behaves the opposite way in some of them. :smiley:
Yesterday I lost some 3d models from the board shown in the video above after selecting the Magenta objects and deleting them (I set Magenta to my temporary objects), because Rhino “secretly” selected some objects with different object colour, too. Luckily, I had an earlier back-up copy and was able to import the missing models. :slight_smile:

I use two different icons for “Select by colour” and “Select by material”, but seems like I will have to use your script instead to make sure there will be no more accidental loss of models. By the way, can you tell me how use the code you posted above? When I run it it evokes a pop-up windows and asks me to open a file. :slight_smile:

P.S.: Is it possible to have this scrips integrated as a native Rhino command? :slight_smile: