There doesn’t seem to be a way to edit the Displaymodes’ GroundPlane altitude in RhinoCommon
https://developer.rhino3d.com/api/rhinocommon/rhino.render.groundplane
Any ideas?
There doesn’t seem to be a way to edit the Displaymodes’ GroundPlane altitude in RhinoCommon
https://developer.rhino3d.com/api/rhinocommon/rhino.render.groundplane
Any ideas?
@dale, is this property accessible via the c++ SDK?
@mrhe - all display mode setting are available in C++.
For ground plane specifically, see CDisplayPipelineAttributes::m_customGroundPlaneSettings.
– Dale
Thanks @dale.
Could you please provide an example on how to use this?
I tried the following code but without success:
void SetGroundPlaneForViewport(ON_UUID viewportId, double elevation)
{
CRhinoDoc* doc = RhinoApp().ActiveDoc();
if (!doc)
return;
auto view = doc->ViewFromViewportId(viewportId);
auto settings = view->DisplayAttributes();
auto test = new CDisplayPipelineAttributes(*settings);
test->SetName("test");
test->m_customGroundPlaneSettings.on = true;
test->m_customGroundPlaneSettings.automaticAltitude = false;
test->m_customGroundPlaneSettings.altitude = elevation;
view->ActiveViewport().SetDisplayMode(test->Id());
}
Edit: found this reference: Rhino - Modifying Advanced Display Settings
Here is the working version if anyone is interested:
void SetGroundPlaneForViewport(double elevation)
{
CRhinoDoc* doc = RhinoApp().ActiveDoc();
if (!doc)
return;
CRhinoView* activeView = RhinoApp().ActiveView();
const UUID displayModeId = activeView->ActiveViewport().View().m_display_mode_id;
DisplayAttrsMgrListDesc* displayMode = CRhinoDisplayAttrsMgr::FindDisplayAttrsDesc(displayModeId);
CDisplayPipelineAttributes* attributes = displayMode->m_pAttrs;
attributes->m_customGroundPlaneSettings.on = true;
attributes->m_customGroundPlaneSettings.automaticAltitude = false;
attributes->m_customGroundPlaneSettings.altitude = elevation;
activeView->Redraw();
}
Hi @mrhe,
Please do something safer, like this:
static bool SetGroundPlaneForViewport(double elevation)
{
bool rc = false;
CRhinoView* pView = RhinoApp().ActiveView();
if (nullptr != pView && ON_IsValid(elevation))
{
const UUID display_mode_id = pView->ActiveViewport().View().m_display_mode_id;
DisplayAttrsMgrListDesc* pDisplayMode = CRhinoDisplayAttrsMgr::FindDisplayAttrsDesc(display_mode_id);
if (nullptr != pDisplayMode)
{
CDisplayPipelineAttributes* pAttrs = pDisplayMode->m_pAttrs;
if (nullptr != pAttrs)
{
pAttrs->m_customGroundPlaneSettings.on = true;
pAttrs->m_customGroundPlaneSettings.automaticAltitude = false;
pAttrs->m_customGroundPlaneSettings.altitude = elevation;
rc = true;
}
}
if (rc)
{
CRhinoDisplayAttrsMgr::SetIsModified(true);
CRhinoDisplayAttrsMgr::SaveProfile(RhinoApp().ProfileContext());
pView->Redraw();
}
}
return rc;
}
Thanks,
– Dale