public static Polyline Get2Point(string command, string command2) { var doc =…
- User
public static Polyline Get2Point(string command, string command2) { var doc = RhinoDoc.ActiveDoc; var points = new List(); Point3d pt0; using (var getPointAction = new GetPoint()) { getPointAction.SetCommandPrompt("Select the first corner of the rectangle:"); if (getPointAction.Get() != GetResult.Point) { RhinoApp.WriteLine("No point was selected."); } pt0 = getPointAction.Point(); }
using (var getPointAction = new GetPoint()) { getPointAction.SetCommandPrompt("Select the opposite corner of the rectangle:"); getPointAction.SetBasePoint(pt0, true); getPointAction.DynamicDraw += (sender, e) => { Point3d pt1 = e.CurrentPoint; // Assuming rectangle is aligned with the construction plane Point3d pt2 = new Point3d(pt1.X, pt0.Y, pt0.Z); Point3d pt3 = new Point3d(pt0.X, pt1.Y, pt1.Z); // Draw the rectangle edges e.Display.DrawPatternedLine(pt0, pt2, Color.CornflowerBlue, 61680, 2); e.Display.DrawPatternedLine(pt2, pt1, Color.CornflowerBlue, 61680, 2); e.Display.DrawPatternedLine(pt1, pt3, Color.CornflowerBlue, 61680, 2); e.Display.DrawPatternedLine(pt3, pt0, Color.CornflowerBlue, 61680, 2); }; if (getPointAction.Get() != GetResult.Point) { RhinoApp.WriteLine("No end point was selected."); } Point3d pt1 = getPointAction.Point(); // (Optionally) Create the rectangle as a Polyline or Curve in Rhino var rectangle = new Polyline(new[] { pt0, new Point3d(pt1.X, pt0.Y, pt0.Z), pt1, new Point3d(pt0.X, pt1.Y, pt1.Z), pt0 }); //doc.Objects.AddPolyline(rectangle); doc.Views.Redraw(); return rectangle; }}
is it possible to get object snap on the rectangle i the 3rd point?
- Assistant