C++ retrieve curson position


How can I retrieve point position without adding or selecting point, only by clicking with mouse on rhino window. The point location is always xy plane.

Should I use:
CRhinoGetPoint gp;

Similarly to command CurveBoolean when it ask to click inside region.
What is the input workflow inside?


one way of doing this is by a “raycast” ->

  • get the mouse screen coordinate (different ways possible)
  • Views.ActiveView.ActiveViewport -> ScreenToClient.
  • Views.ActiveView.ActiveViewport -> ClientToWorld -> returns a line/ray
  • Line -> Closest Point

To get screen to client. How to get it?

It does not work like this:
ON_Point* pt;
CRhinoView v;

Well I don’t know for C++, I’ve tried that with C#. But it should work similar. See pm

It was as simple as this:

// Prompt for base point
CRhinoGetPoint gp;
gp.SetCommandPrompt(L"Base point");
if (gp.CommandResult() != CRhinoCommand::success)
	return gp.CommandResult();

// Get first picked point
ON_3dPoint origin = gp.Point();
1 Like