示例#1
0
        public void SetConstructionPlane(RhinoDoc doc, string viewname)
        {
            if (viewname == "Top")
            {
                var A_plane = Z_minus_plane;
                setCplane("Top", A_plane);
            }
            else if (viewname == "Front")
            {
                var A_plane = Y_minus_plane;
                setCplane("Front", A_plane);
            }
            else if (viewname == "Right")
            {
                var A_plane = X_plus_plane;
                setCplane("Right", A_plane);
            }

            void setCplane(string Viewname, Plane a_plane)
            {
                //To set Constructionplane for "Front" view
                Rhino.Display.RhinoView            view   = doc.Views.Find(Viewname, true);
                Rhino.DocObjects.ConstructionPlane cplane = view.ActiveViewport.GetConstructionPlane();
                Point3d origin = cplane.Plane.Origin;
                Plane   pl     = cplane.Plane;

                pl.Origin    = a_plane.Origin;
                cplane.Plane = pl;
                view.ActiveViewport.SetConstructionPlane(cplane);
            }
        }
 internal static ConstructionPlane FromIntPtr(IntPtr pConstructionPlane)
 {
   if (IntPtr.Zero == pConstructionPlane)
     return null;
   ConstructionPlane rc = new ConstructionPlane();
   using (var sh = new StringHolder())
   {
     IntPtr ptr_string = sh.NonConstPointer();
     UnsafeNativeMethods.ON_3dmConstructionPlane_Copy(pConstructionPlane,
                                                      ref rc.m_plane,
                                                      ref rc.m_grid_spacing,
                                                      ref rc.m_snap_spacing,
                                                      ref rc.m_grid_line_count,
                                                      ref rc.m_grid_thick_frequency,
                                                      ref rc.m_bDepthBuffered,
                                                      ptr_string);
     rc.m_name = sh.ToString();
   }
   return rc;
 }
    public static Rhino.Commands.Result MoveCPlane(Rhino.RhinoDoc doc)
    {
        Rhino.Display.RhinoView view = doc.Views.ActiveView;
        if (view == null)
        {
            return(Rhino.Commands.Result.Failure);
        }

        Rhino.DocObjects.ConstructionPlane cplane = view.ActiveViewport.GetConstructionPlane();
        Point3d origin = cplane.Plane.Origin;

        MoveCPlanePoint gp = new MoveCPlanePoint(cplane);

        gp.SetCommandPrompt("CPlane origin");
        gp.SetBasePoint(origin, true);
        gp.DrawLineFromPoint(origin, true);
        gp.Get();

        if (gp.CommandResult() != Rhino.Commands.Result.Success)
        {
            return(gp.CommandResult());
        }

        Point3d  point = gp.Point();
        Vector3d v     = origin - point;

        if (v.IsTiny())
        {
            return(Rhino.Commands.Result.Nothing);
        }

        Plane pl = cplane.Plane;

        pl.Origin    = point;
        cplane.Plane = pl;
        view.ActiveViewport.SetConstructionPlane(cplane);
        view.Redraw();
        return(Rhino.Commands.Result.Success);
    }
        internal static ConstructionPlane FromIntPtr(IntPtr pConstructionPlane)
        {
            if (IntPtr.Zero == pConstructionPlane)
            {
                return(null);
            }
            ConstructionPlane rc = new ConstructionPlane();

            using (var sh = new StringHolder())
            {
                IntPtr ptr_string = sh.NonConstPointer();
                UnsafeNativeMethods.ON_3dmConstructionPlane_Copy(pConstructionPlane,
                                                                 ref rc.m_plane,
                                                                 ref rc.m_grid_spacing,
                                                                 ref rc.m_snap_spacing,
                                                                 ref rc.m_grid_line_count,
                                                                 ref rc.m_grid_thick_frequency,
                                                                 ref rc.m_bDepthBuffered,
                                                                 ptr_string);
                rc.m_name = sh.ToString();
            }
            return(rc);
        }
 public MoveCPlanePoint(Rhino.DocObjects.ConstructionPlane cplane)
 {
   m_cplane = cplane;
 }
 public MoveCPlanePoint(Rhino.DocObjects.ConstructionPlane cplane)
 {
     m_cplane = cplane;
 }