Disable selection of object

How to disable selecting object in rhino? I tried a locked mode, but I need specific colors.

        ObjectAttributes attr = new ObjectAttributes();
        attr.Name = "Name"
        attr.ColorSource = ObjectColorSource.ColorFromObject;
        attr.ObjectColor = Color.YellowGreen;
        attr.Mode = ObjectMode.Locked;

after code like this object have locked color.
Is there another way to disable selecting?

@RafalF, you can only lock the object or the layer. The Color of locked objects or objects on locked layers depends on the display mode setting for locked object usage:

_
c.

Great. It’s working like I wanted. Do you know how change that property using programming? I found only how to change locked color…
Rhino.ApplicationSettings.AppearanceSettings.LockedObjectColor = Color.WhiteSmoke;

Hi @RafalF,

the display mode settings are not changeable via RhinoCommon as far as i understand. But you could create your own displaymode with the required settings for locked object color usage and assign this display mode to your object using a scripted command of _SetObjectDisplayMode.

_
c.

Thanks for answers @clement ,

Do you mean DisplayModeDescription class?
http://developer.rhino3d.com/api/RhinoCommon/html/T_Rhino_Display_DisplayModeDescription.htm
I found a lot of great functions and variables, but could not find anything that would help me with locked color problem :confused:

Hi @RafalF,

The setting to control the locked object color you’ve found is the only one i know. It works application wide, so when a display mode is set to “Use Application Settings” for the “Locked Objects / Locked object usage” dropdown, then this color is used.

The setting to change for the specific display mode is not exposed yet in RhinoCommon as far as i see. There are a few other settings shown here… i see nothing to change the locked object color usage.

My suggestion would be to manually create your own display mode having the setting changed already, then try to apply this mode to the objects programmatically.

_
c.

Thanks again @clement for answering.

I did it in another way. Much simpler. I defined my own Layer and locked it. Objects in locked layers doesn’t changing color.

Thanks for help. We can close

@RafalF, yes this is what i wrote in my first reply. Great it is working for you now.

_
c.