Change object color in Display Conduit

I tried to change the color of some objects in the Display Conduit, but had no luck with the following code:

var obj = e.RhinoObject;
obj.Attributes.ColorSource = Rhino.DocObjects.ObjectColorSource.ColorFromObject;
Color c = obj.Attributes.ObjectColor;
obj.Attributes.ObjectColor = Color.FromArgb(ac.DrawAlpha, c.R, c.G, c.B);

The color assignment in the last line doesn’t work. Any ideas, why?

Did you use obj.commitchanges() after you set the objectcolor?

Hi Jordy,

thanks for your help. The problem was that you can’t change the alpha value of the attributes’ object color, so this particular assignment won’t work. I tried it without the alpha value and it worked.

OK, so now I have to ask again a slightly different question. I actually didn’t want to change the objects’ real attributes, but only their display color.

The idea is to take the background color and mix it with the objects’ color to simulate a transparency effect. Therefore, I need to query the background color, do some calculations and apply the new color as display color to the respective objects.

Apparently, in C++, I can get the background with CDisplayPipelineAttributes::m_SolidColor and apply it to the objects using CDisplayPipelineAttributes::m_ObjectColor.

Now, in RhinoCommon, I have two problems:

  1. How can I get the background color?
  2. Why does e.Display.DisplayPipelineAttributes.ObjectColor = Color.Red not work to apply a custom color?

Hi thomas, all.

I’m also trying to change an object’s colour at draw time using a display conduit in rhinocommon. I so far also haven’t found a satisfying approach to achieve this. Have you or anyone else found a solution since?

Thanks seb

Hi Seb,

this seems to be a bug / missing feature in RhinoCommon: http://mcneel.myjetbrains.com/youtrack/issue/RH-32669

I’m not sure if you hace access to the bugtracker, but if you do, you can track the progress and maybe vote for this issue :wink: