Hello, I would like to know if there is a way to select a polysurface and treat this as a surface using c++, I am using Rhino 5 by the way. I mean, for example if I had a polysurface and I want to get the area and centroid, how could I write a line of code to do this or which type of ON_geometry would it be.
For example for getting a surface I type these lines of code
CRhinoGetObject go;
go.SetCommandPrompt( L"Select surface" );
go.SetGeometryFilter( CRhinoGetObject::surface_object );
go.GetObjects( 1, 1 );
if( go.CommandResult() != success )
return go.CommandResult();
// Validate selection
const CRhinoObjRef& refSurf = go.Object(0);
const CRhinoObject* objSurf = refSurf.Object();
const ON_Surface* srf = refSurf.Surface();
if( !srf )
return failure;
but it doesnt work for polysurfaces, would there be a way to select a polysurface?
Thank you
dale
(Dale Fugier)
May 18, 2018, 6:15pm
2
Hi @f.leon.marquez95 ,
If you want to select polysurfaces, then use the CRhinoGetObject::polysrf_object
. For example:
CRhinoGetObject go;
go.SetGeometryFilter(CRhinoGetObject::polysrf_object);
If you want to select both surface and polysurfaces then include the CRhinoGetObject::surface_object
filter:
CRhinoGetObject go;
go.SetGeometryFilter(CRhinoGetObject::surface_object | CRhinoGetObject::polysrf_object);
Another example:
CRhinoGetObject go;
go.SetCommandPrompt(L"Select polysurface");
go.SetGeometryFilter(CRhinoGetObject::polysrf_object);
go.GetObjects(1, 1);
if (go.CommandResult() != success)
return go.CommandResult();
const CRhinoObjRef& objref = go.Object(0);
const ON_Brep* brep = objref.Brep();
if (brep)
{
ON_MassProperties mp;
if (brep->AreaMassProperties(mp, true, false, false, false))
{
// TODO...
}
}
– Dale