Creating attributes isn't added directly in Rhino

Hello,

I’m adding a new attribute with
auto* displayAttrb = CRhinoDisplayAttrsMgr::CreateNewAttrs(APP_NAME, {}); and after setting all the settings, I call these two:
CRhinoDisplayAttrsMgr::UpdateAttributes(*displayAttrb); CRhinoDisplayAttrsMgr::SaveProfile(RhinoApp().ProfileContext()); const auto view = RhinoApp().ActiveView(); view->ActiveViewport().SetDisplayMode(displayAttrb->m_pAttrs->Id()); view->Redraw();

However, the new view attribute doesn’t show in Rhino and isn’t set unless I restart Rhino.
What should be done to have it added in Rhino and used directly?
Thanks

Hi @blondbeer,

Does this work for you?

CRhinoCommand::result CCommandTest::RunCommand(const CRhinoCommandContext& context)
{
  CRhinoView* pView = RhinoApp().ActiveView();
  if (nullptr == pView)
    return CRhinoCommand::failure;

  DisplayAttrsMgrListDesc* pAttrsDesc = CRhinoDisplayAttrsMgr::FindDisplayAttrsDesc(EnglishCommandName());
  if (nullptr == pAttrsDesc)
  {
    pAttrsDesc = CRhinoDisplayAttrsMgr::CreateNewAttrs(EnglishCommandName(), ON_StandardDisplayModeId::Shaded);
    if (nullptr == pAttrsDesc || nullptr == pAttrsDesc->m_pAttrs)
      return CRhinoCommand::failure;

    // Set up some default stuff
    pAttrsDesc->m_bWireframePipelineRequired = false;
    pAttrsDesc->m_pAttrs->m_bUseObjectMaterial = false;
    pAttrsDesc->m_pAttrs->m_bShadeSurface = false;
    pAttrsDesc->m_pAttrs->m_pMaterial->m_bFrontIsCustom = false;
    pAttrsDesc->m_pAttrs->m_pMaterial->m_bBackIsCustom = false;
    pAttrsDesc->m_pAttrs->m_pMaterial->m_bUseBackMaterial = false;
    pAttrsDesc->m_pAttrs->m_eLightingScheme = LS_DEFAULT_LIGHTING;

    CRhinoDisplayAttrsMgr::SetIsModified(true);
  }

  pView->ActiveViewport().SetDisplayMode(pAttrsDesc->m_pAttrs->Id());
  pView->Redraw();

  return CRhinoCommand::success;
}

– Dale