Hello there, I want to make an script in c++ for Rhino 5 in order to let the user select a point on a surface and then get the coordinates of this point. I have looked for code but I havent found anything. And I was wondering if someone knows a way to do this.
Your command’s RunCommand method might look something like this:
CRhinoCommand::result CCommandTest::RunCommand(const CRhinoCommandContext& context)
{
// Prompt the user to select a surface (e.g. Brep face)
CRhinoGetObject go;
go.SetCommandPrompt(L"Select surface");
go.SetGeometryFilter(CRhinoGetObject::surface_object);
go.GetObjects(1, 1);
if (go.CommandResult() != CRhinoCommand::success)
return go.CommandResult();
// Get the selected Brep face
const CRhinoObjRef& obj_ref = go.Object(0);
const ON_BrepFace* face = obj_ref.Face();
if (nullptr == face)
return CRhinoCommand::failure;
// Pick a point that is constrained to the Brep face
CRhinoGetPoint gp;
gp.SetCommandPrompt(L"Pick location on surface");
gp.Constrain(*face);
gp.GetPoint();
if (gp.CommandResult() != CRhinoCommand::success)
return gp.CommandResult();
ON_3dPoint point = gp.Point();
// Print results
ON_wString point_str;
RhinoFormatPoint(point, point_str);
RhinoApp().Print(L"Surface point = %s\n", static_cast<const wchar_t*>(point_str));
// Optional - add to the document
context.m_doc.AddPointObject(point);
context.m_doc.Redraw();
return CRhinoCommand::success;
}
Thank you very much, I could find a point. And in case i would like to display axis as if i were executing extractIsocurve. Would it be a way to do this?
I am working on Rhino 5 and the override keyword gives me error for the functions with it and the method DrawCurve doesnt exist. Is there any other way to solve this problem?
Hello, as long as I am using the Rhino 5 and Visual Studio 2010, I cannot use the method DrawCurve in the line code dp.DrawCurve(*m_curves[i]); saying that CRhinoDisplayPipeline does not have the method DrawCurve. Can I use another method? I just want to draw the x and y axis