예제 #1
0
        ///<summary> This gets called when when the user runs this command.</summary>
        public override IRhinoCommand.result RunCommand(IRhinoCommandContext context)
        {
            MRhinoGetObject go = new MRhinoGetObject();

            go.SetCommandPrompt("Select object to move");
            go.EnableSubObjectSelect(false);
            go.GetObjects(1, 1);
            if (go.CommandResult() != IRhinoCommand.result.success)
            {
                return(go.CommandResult());
            }

            MRhinoGetPoint gp = new MRhinoGetPoint();

            gp.SetCommandPrompt("Point to move from");
            gp.GetPoint();
            if (gp.CommandResult() != IRhinoCommand.result.success)
            {
                return(gp.CommandResult());
            }

            On3dPoint pointFrom = gp.Point();

            gp.SetCommandPrompt("Point to move to");
            gp.SetBasePoint(pointFrom);
            gp.DrawLineFromPoint(pointFrom, true);
            gp.GetPoint();
            if (gp.CommandResult() != IRhinoCommand.result.success)
            {
                return(gp.CommandResult());
            }

            On3dPoint pointTo = gp.Point();

            On3dVector dir = new On3dVector(pointTo - pointFrom);

            if (dir.IsTiny())
            {
                return(IRhinoCommand.result.nothing);
            }

            OnXform xform = new OnXform();

            xform.Translation(dir);

            MRhinoObjRef objectRef = go.Object(0);

            context.m_doc.TransformObject(ref objectRef, xform);
            context.m_doc.Redraw();

            return(IRhinoCommand.result.success);
        }
        ///<summary> This gets called when when the user runs this command.</summary>
        public override IRhinoCommand.result RunCommand(IRhinoCommandContext context)
        {
            MRhinoGetObject go = new MRhinoGetObject();
              go.SetCommandPrompt("Select object to move");
              go.EnableSubObjectSelect(false);
              go.GetObjects(1, 1);
              if (go.CommandResult() != IRhinoCommand.result.success)
            return go.CommandResult();

              MRhinoGetPoint gp = new MRhinoGetPoint();
              gp.SetCommandPrompt("Point to move from");
              gp.GetPoint();
              if (gp.CommandResult() != IRhinoCommand.result.success)
            return gp.CommandResult();

              On3dPoint pointFrom = gp.Point();

              gp.SetCommandPrompt("Point to move to");
              gp.SetBasePoint(pointFrom);
              gp.DrawLineFromPoint(pointFrom, true);
              gp.GetPoint();
              if (gp.CommandResult() != IRhinoCommand.result.success)
            return gp.CommandResult();

              On3dPoint pointTo = gp.Point();

              On3dVector dir = new On3dVector(pointTo - pointFrom);
              if (dir.IsTiny())
            return IRhinoCommand.result.nothing;

              OnXform xform = new OnXform();
              xform.Translation(dir);

              MRhinoObjRef objectRef = go.Object(0);
              context.m_doc.TransformObject(ref objectRef, xform);
              context.m_doc.Redraw();

              return IRhinoCommand.result.success;
        }