ON_StandardDisplayModeId at CRhinoObject

Hi, I need to set the ON_StandardDisplayModeId (to ON_StandardDisplayModeId::Shaded) at a CRhinoObject (Rhino5 and Rhnio6 both).
Is it possible, how?

Hi @ceruti,

This works in Rhino 6:

CRhinoCommand::result CCommandTest::RunCommand(const CRhinoCommandContext& context)
  CRhinoGetObject go;
  go.SetCommandPrompt(L"Select objects to set to shaded display mode");
  go.GetObjects(1, 0);
  if (go.CommandResult() != CRhinoCommand::success)
    return go.CommandResult();

  CRhinoView* view = RhinoApp().ActiveView();
  if (nullptr == view)
    return CRhinoCommand::failure;

  ON_DisplayMaterialRef display_mat_ref;
  display_mat_ref.m_viewport_id = view->ActiveViewport().VP().ViewportId();
  display_mat_ref.m_display_material_id = ON_StandardDisplayModeId::Shaded;

  for (int i = 0; i < go.ObjectCount(); i++)
    const CRhinoObjRef& obj_ref = go.Object(i);
    const CRhinoObject* obj = obj_ref.Object();
    if (nullptr != obj)
      CRhinoObjectAttributes attributes = obj->Attributes();
      if (!attributes.FindDisplayMaterialRef(display_mat_ref, &display_mat_ref))
        context.m_doc.ModifyObjectAttributes(obj_ref, attributes);


  return CRhinoCommand::success;

– Dale

Great. Now is ok.
Only a last problem: I can’t set the correct color:. I

		CRhinoObjectAttributes  m_attr = m_p_obj->Attributes();
		m_attr.m_color = ON_Color(255, 0, 0);
		if (!m_attr.FindDisplayMaterialRef(m_display_mat_ref, &m_display_mat_ref)) {
			RhinoApp().ActiveDoc()->ModifyObjectAttributes(m_p_obj, m_attr);
                        m_attr.m_color = ON_Color(255, 0, 0);

Can you help me?

Sorry, I can.
Thanks anyway.