public static List<Point3d> GetUserDefinedPointsForDimension(double…
- User
public static List GetUserDefinedPointsForDimension(double drawScale,DimensionStyle dimStyle, string prompt) { List points = new List();
code// Get the first point from the user Point3d firstPoint = GetPointFromUser(prompt + " First Point: "); if (!firstPoint.IsValid) { RhinoApp.WriteLine("Invalid first point."); return points; } points.Add(firstPoint); // Get the second point from the user with dynamic line feedback using (var getPointAction = new GetPoint()) { getPointAction.SetCommandPrompt(prompt + " Second Point: "); getPointAction.DynamicDraw += (sender, e) => { e.Display.DrawLine(firstPoint, e.CurrentPoint, System.Drawing.Color.DarkCyan); }; if (getPointAction.Get() == GetResult.Point) { Point3d secondPoint = getPointAction.Point(); if (!secondPoint.IsValid) { RhinoApp.WriteLine("Invalid second point."); return points; } points.Add(secondPoint); } else { RhinoApp.WriteLine("Second point selection cancelled."); return points; } } // Get the third point from the user with dynamic dimension feedback using (var getPointAction = new GetPoint()) { getPointAction.SetCommandPrompt(prompt + " Third Point: "); getPointAction.DynamicDraw += (sender, e) => { Plane currentDocPlane = RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.ConstructionPlane(); Transform rotation = Transform.Rotation(Math.PI / 2, Point3d.Origin); currentDocPlane.Transform(rotation); LinearDimension dimension = LinearDimension.Create( AnnotationType.Aligned, dimStyle, currentDocPlane, currentDocPlane.XAxis, points[0], points[1], e.CurrentPoint, 0); e.Display.DrawAnnotation(dimension, System.Drawing.Color.DarkCyan); }; if (getPointAction.Get() == GetResult.Point) { Point3d thirdPoint = getPointAction.Point(); if (!thirdPoint.IsValid) { RhinoApp.WriteLine("Invalid third point."); return points; } points.Add(thirdPoint); } else { RhinoApp.WriteLine("Third point selection cancelled."); return points; } } return points; - Assistant