Preserve and display color source of object, when its layer is locked

Hi.
I am developing a Rhino-plugin using RhinoCommon. I know how to set the color source of some geometry using ObjectColorSource. But when I lock the layer, the color of the geometry takes after the lock color. Is it possible for the geometry to preserve and display its color source, when its layer is locked? Example: An object with an orange object color remains orange, when its layer is locked.

I am not sure this should happen. Can you provide some sample code?

Giulio

Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com

//Add sphere to document and color it orange
Sphere sphere = new Sphere(new Point3d(0, 0, 0), 20);
Guid id = doc.Objects.AddSphere(sphere);
RhinoObject rhinoObject = doc.Objects.Find(id);
rhinoObject.Attributes.ObjectColor = System.Drawing.Color.Orange;
rhinoObject.Attributes.ColorSource = ObjectColorSource.ColorFromObject;

//upon locking the layer, the sphere turns dark grey. Not what I want :wink:
rhinoObject.Attributes.Mode = ObjectMode.Locked;
rhinoObject.CommitChanges();

All locked objects in Rhino use the “locked object” color. You can find this color in the options dialog under the Appearance->Colors section.

If you want to force the object to always have a certain color, you would need to write a display conduit to override the default behavior.

I am 5 minutes into learning about display conduits and realised that the answer to this question probably related to this. Thank you.