LockObject Color/CRhinoObjectAttributes problem

Hi,
I need to lock one object and define the material of this object too.
The problem is that using LockObject function the object became gray.
Is there the possibilty to keep (or set in second stage) the object color?
Thanks
Teo

Hi @ceruti,

My apologies, but I do not understand what you want to do. Do you want to change the render material of a locked object? Or do you want to change the object color of a locked object? Or do you want a locked object to draw with a color other than gray?

Any additional information you can provide on what you are trying to do and why might be helpful.

Thanks,

– Dale

Hi, I need to show a ON_Surface in shaded mode and with a defined color. And the surface must be locked.
I used:
ON_SimpleArray<ON_DisplayMaterialRef> m_display_mat_ref;

ON_SimpleArray<CRhinoView*> view_list;
p_doc->GetViewList(view_list);
for (int i = 0; i < view_list.Count(); i++) {
	if (view_list[i] == NULL) {
		continue;
	}
	m_display_mat_ref.Append(ON_DisplayMaterialRef());
	m_display_mat_ref.Last()->m_viewport_id = view_list[i]->ActiveViewport().VP().ViewportId();
	m_display_mat_ref.Last()->m_display_material_id = ON_StandardDisplayModeId::Shaded;
}
CRhinoObjectAttributes  m_attr = m_surf->Attributes();

m_attr.SetColorSource(ON::color_from_object);

p_doc->ModifyObjectAttributes(m_surf, m_attr);
and all is ok, but when I set
p_doc->LockObject(m_surf.first, false);
the surface became gray.
For now I put the surfaces on a layer and locked it, but it should be better to lock single object.
Thanks
Teo

Hi @ceruti,

If you want your locked surface to appear differently than other locked surfaces when in Shaded mode, then you might consider using a conduit to override the shaded material colors when drawing.

I’ve attached a sample for you to review.

cmdTestTeo.cpp (2.8 KB)

– Dale