Problem with using a modified construction plane in the plug-in


I’m trying to use a picked object to move and rotate the CPlane in Rhino, and then create a new geometry (e.g. a surface) based on the new construction plane coordinates. I successfully move the CPlane to the desired location, but when I try to add a new object (inside the plugin) to the Rhino document, it takes the World coordinate system. However, if I try to interactively add, let’s say, a point to my document, it uses the construction plane coordinate system!

So, I’m doing something like this:

  1. I ask the user to pick a circle object.

  2. then I get the origin and the plane of this circle from OpenNURBS.

  3. I get the current construction plane:
    CRhinoView* view = ::RhinoApp().ActiveView();
    if (!view)
    return CRhinoCommand::failure;

ON_3dmConstructionPlane cplane = view->Viewport().ConstructionPlane();

  1. I modify the m_plane of the construction plane
    cplane.m_plane.CreateFromNormal(New_Origin, Normal_To_The_Plane);

  2. I set the new construction plane and redraw:

at this point, I can see in the debug-mode that the construction plane has moved successfully.

  1. Then I send the radius of the circle to a function where I define a NURBS surface based on that.
    ON_NurbsSurface Base_Surface = CreateTheBaseSurface(Radius);
    (I take the origin for this surface to be (0,0,0))

  2. Finally, I add the surface object to the document and redraw:
    context.m_doc.AddSurfaceObject(Base_Surface );

But, the surface pops in the World’s coordinate system.

I have tried many things, but couldn’t figure out what the problem is. Am I missing something here?

I know that I can transform my object to the place that I want, but it would be easier if the construction plane thing were working.

Any help regarding this is greatly appreciated.

P.S.: I’m writing the plug-in in C++ and Rhino 6.
P.S.2: view->Viewport().PushConstructionPlane(cplane) also doesn’t work

Hi @resammc,

Geometry is already created in the world (x-y) coordinates. If you want your geometry to lie on some other plane, you’ll need to transform it to that plane. For example:

CRhinoCommand::result CCommandTest6::RunCommand(const CRhinoCommandContext& context)
  CRhinoView* view = RhinoApp().ActiveView();
  if (nullptr == view)
    return CRhinoCommand::failure;

  // Change the viewport's construction plane to the world-zx plane
  ON_3dmConstructionPlane cplane = view->ActiveViewport().ConstructionPlane();
  cplane.m_plane.CreateFromFrame(ON_3dPoint::Origin, ON_3dVector::ZAxis, ON_3dVector::XAxis);

  // Create plane surface that lies on the world-xy plane
  ON_PlaneSurface plane_srf(ON_Plane::World_xy);
  plane_srf.SetExtents(0, ON_Interval(0.0, 20.0), true);
  plane_srf.SetExtents(1, ON_Interval(0.0, 10.0), true);

  // Transform the plane surface to lie on the new cplane
  ON_Xform xform;
  xform.Rotation(ON_Plane::World_xy, cplane.m_plane);


  return CRhinoCommand::success;

Hope this helps.

– Dale

1 Like

Hi @dale,

Thanks a lot for the clarification. Then, I will use the transformation functions.