public static Result Ortho(RhinoDoc doc) { var gp = new GetPoint(); gp.SetCommandPrompt("Start of line"); gp.Get(); if (gp.CommandResult() != Result.Success) return gp.CommandResult(); var start_point = gp.Point(); var original_ortho = ModelAidSettings.Ortho; if (!original_ortho) ModelAidSettings.Ortho = true; gp.SetCommandPrompt("End of line"); gp.SetBasePoint(start_point, false); gp.DrawLineFromPoint(start_point, true); gp.Get(); if (gp.CommandResult() != Result.Success) return gp.CommandResult(); var end_point = gp.Point(); if (ModelAidSettings.Ortho != original_ortho) ModelAidSettings.Ortho = original_ortho; doc.Objects.AddLine(start_point, end_point); doc.Views.Redraw(); return Result.Success; }
protected override Result RunCommand(Rhino.RhinoDoc doc, RunMode mode) { // TODO: start here modifying the behaviour of your command. // --- RhinoApp.WriteLine ("The {0} command will add a line right now.", EnglishName); Point3d pt0; using (GetPoint getPointAction = new GetPoint ()) { getPointAction.SetCommandPrompt ("Please select the start point"); if (getPointAction.Get () != GetResult.Point) { RhinoApp.WriteLine ("No start point was selected."); return getPointAction.CommandResult (); } pt0 = getPointAction.Point (); } Point3d pt1; using (GetPoint getPointAction = new GetPoint ()) { getPointAction.SetCommandPrompt ("Please select the end point"); getPointAction.SetBasePoint (pt0, true); getPointAction.DrawLineFromPoint (pt0, true); if (getPointAction.Get () != GetResult.Point) { RhinoApp.WriteLine ("No end point was selected."); return getPointAction.CommandResult (); } pt1 = getPointAction.Point (); } doc.Objects.AddLine (pt0, pt1); doc.Views.Redraw (); RhinoApp.WriteLine ("The {0} command added one line to the document.", EnglishName); return Result.Success; }
public static Rhino.Commands.Result AddLine(Rhino.RhinoDoc doc) { Rhino.Input.Custom.GetPoint gp = new Rhino.Input.Custom.GetPoint(); gp.SetCommandPrompt("Start of line"); gp.Get(); if (gp.CommandResult() != Rhino.Commands.Result.Success) return gp.CommandResult(); Rhino.Geometry.Point3d pt_start = gp.Point(); gp.SetCommandPrompt("End of line"); gp.SetBasePoint(pt_start, false); gp.DrawLineFromPoint(pt_start, true); gp.Get(); if (gp.CommandResult() != Rhino.Commands.Result.Success) return gp.CommandResult(); Rhino.Geometry.Point3d pt_end = gp.Point(); Rhino.Geometry.Vector3d v = pt_end - pt_start; if (v.IsTiny(Rhino.RhinoMath.ZeroTolerance)) return Rhino.Commands.Result.Nothing; if (doc.Objects.AddLine(pt_start, pt_end) != Guid.Empty) { doc.Views.Redraw(); return Rhino.Commands.Result.Success; } return Rhino.Commands.Result.Failure; }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { ObjRef[] obj_refs; var rc = RhinoGet.GetMultipleObjects("Select points to move", false, ObjectType.Point, out obj_refs); if (rc != Result.Success || obj_refs == null) return rc; var gp = new GetPoint(); gp.SetCommandPrompt("Point to move from"); gp.Get(); if (gp.CommandResult() != Result.Success) return gp.CommandResult(); var start_point = gp.Point(); gp.SetCommandPrompt("Point to move to"); gp.SetBasePoint(start_point, false); gp.DrawLineFromPoint(start_point, true); gp.Get(); if (gp.CommandResult() != Result.Success) return gp.CommandResult(); var end_point = gp.Point(); var xform = Transform.Translation(end_point - start_point); foreach (var obj_ref in obj_refs) { doc.Objects.Transform(obj_ref, xform, true); } doc.Views.Redraw(); return Result.Success; }
protected override Result RunCommand(RhinoDoc doc, RunMode mode) { Loop loop = new Loop(); loop.Run(doc); return Result.Success; // TODO: start here modifying the behaviour of your command. // --- RhinoApp.WriteLine("The {0} command will add a line right now.", EnglishName); Point3d pt0; using (GetPoint getPointAction = new GetPoint()) { getPointAction.SetCommandPrompt("Please select the start point"); if (getPointAction.Get() != GetResult.Point) { RhinoApp.WriteLine("No start point was selected."); return getPointAction.CommandResult(); } pt0 = getPointAction.Point(); } Point3d pt1; using (GetPoint getPointAction = new GetPoint()) { getPointAction.SetCommandPrompt("Please select the end point"); getPointAction.SetBasePoint(pt0, true); getPointAction.DynamicDraw += (sender, e) => e.Display.DrawLine(pt0, e.CurrentPoint, System.Drawing.Color.DarkRed); if (getPointAction.Get() != GetResult.Point) { RhinoApp.WriteLine("No end point was selected."); return getPointAction.CommandResult(); } pt1 = getPointAction.Point(); } doc.Objects.AddLine(pt0, pt1); doc.Views.Redraw(); RhinoApp.WriteLine("The {0} command added one line to the document.", EnglishName); // --- return Result.Success; }
public static Result ConduitArrowHeads(RhinoDoc doc) { if (m_draw_conduit != null) { RhinoApp.WriteLine("Turn off existing arrowhead conduit"); m_draw_conduit.Enabled = false; m_draw_conduit = null; } else { // get arrow head size var go = new GetOption(); go.SetCommandPrompt("ArrowHead length in screen size (pixels) or world size (percentage of arrow length)?"); go.AddOption("screen"); go.AddOption("world"); go.Get(); if (go.CommandResult() != Result.Success) return go.CommandResult(); int screen_size = 0; double world_size = 0.0; if (go.Option().EnglishName == "screen") { var gi = new GetInteger(); gi.SetLowerLimit(0, true); gi.SetCommandPrompt("Length of arrow head in pixels"); gi.Get(); if (gi.CommandResult() != Result.Success) return gi.CommandResult(); screen_size = gi.Number(); } else { var gi = new GetInteger(); gi.SetLowerLimit(0, true); gi.SetUpperLimit(100, false); gi.SetCommandPrompt("Length of arrow head in percentage of total arrow length"); gi.Get(); if (gi.CommandResult() != Result.Success) return gi.CommandResult(); world_size = gi.Number() / 100.0; } // get arrow start and end points var gp = new GetPoint(); gp.SetCommandPrompt("Start of line"); gp.Get(); if (gp.CommandResult() != Result.Success) return gp.CommandResult(); var start_point = gp.Point(); gp.SetCommandPrompt("End of line"); gp.SetBasePoint(start_point, false); gp.DrawLineFromPoint(start_point, true); gp.Get(); if (gp.CommandResult() != Result.Success) return gp.CommandResult(); var end_point = gp.Point(); var v = end_point - start_point; if (v.IsTiny(Rhino.RhinoMath.ZeroTolerance)) return Result.Nothing; var line = new Line(start_point, end_point); m_draw_conduit = new DrawArrowHeadsConduit(line, screen_size, world_size); // toggle conduit on/off m_draw_conduit.Enabled = true; RhinoApp.WriteLine("Draw arrowheads conduit enabled."); } doc.Views.Redraw(); return Result.Success; }