Get point along a line, is the cursor actually close on left or close on the right of it?

Hello Forum,

I need to dynamically draw a hatch along a line. I’m using GetPoint and I’m enabling snapToCurve. By calling PointOnCurve the system gives me both the closest line, if any, and the line coordinate of the closest point with respect to the pointer position.

The hatch can be on the left or on the right of the line and I want to set this direction through the actual position of the pointer with respect of the snapped point.

How can I understand if the cursor is actually close on the left or close on the right of the line?

Thanks. L

Hi @lscandella

This should get you started:

CRhinoGetPoint gp;
gp.GetPoint();
if (gp.CommandResult() == CRhinoCommand::success)
{
  ON_3dPoint pick_point = gp.Point();
  ON_3dPoint screen_point = ON_UNSET_POINT;

  CRhinoView* view = gp.View();
  if (nullptr != view)
  {
    CPoint pt;
    if (GetCursorPos(&pt))
    {
      ON_Xform screen_to_world;
      view->ActiveViewport().VP().GetXform(ON::screen_cs, ON::world_cs, screen_to_world);
      screen_point = screen_to_world * pt;
    }
  }

  if (screen_point.IsValid())
  {
    // TODO: figure out what to do here...
  }
}

– Dale

Dale,

thanks. Perfect as usual!

By the way, how can I get the Guid of the curve returned by PointOnCurve method? I tried curve.GetType().GUID, but the result is wrong…

Thanks. L

Hi @lscandella,

No, PointOnCurve just returns the curve object, not the owning Rhino object. However, if you contraining picking to a known curve, you should have the id of the object.

– Dale