Hi,
I was trying to get ON_PlanarSections::AttachToObject
running, but so far I have not been able to see a result. Also, I don’t know exactly what to expect as a result so that doesn’t really help.
So far, this is what I have. After AttachToObject, which is successful, what is supposed to happen? Should I be able to see something in the document? Can I query the planarsections object somehow? When the object updates, are the planar sections automatically updated too?
Any hints on how to proceed are much appreciated!
CRhinoObjRef objRef; // obtained by selecting one surface_object
const CRhinoObject* obj = objRef.Object();
if (!obj)
{
// when nothing was selected there isn't anything left to do.
return nothing;
}
obj->Select(false);
const ON_Surface* srf = objRef.Surface();
if (!srf)
return nothing;
ON_SimpleArray<const ON_Mesh*> arr;
obj->GetMeshes(ON::mesh_type::any_mesh, arr);
if (arr.Count() == 0)
{
ON_MeshParameters mp;
mp.DefaultAnalysisMeshParameters();
ON_Mesh* m = srf->CreateMesh(mp);
arr.Append(m);
}
ON_Plane xp(ON_3dPoint(0,0,0), ON_3dVector(1,0,0));
ON_MeshXPlane mxp( *(arr[0]), 0);
ON_SectionAnalysisPlane p;
p.m_plane_equation = xp.plane_equation;
if (!ON_PlanarSections::AttachToObject(obj, mxp, srf, ON_SectionAnalysisAppearance::Default, p))
RhinoApp().Print("Failed to attach planar sections to object\n");
context.m_doc.Redraw();
return success;