hello everyone.
i can’t snap to horizontal line or vertical line on DynamicDrawing .
there is a example.
and this is my code
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
var type = ObjectType.Annotation | ObjectType.Surface | ObjectType.Point | ObjectType.Brep | ObjectType.Curve;
doc.Views.ActiveView.ActiveViewport.DisplayGrips(true, type);
var result = RhinoGet.GetGrips(out var grips, "Select Grips");
if (result != Result.Success)
{
doc.Views.ActiveView.ActiveViewport.DisplayGrips(false, type);
return result;
}
var basePoint = Point3dEx.Average(grips.Select(g => g.CurrentLocation));
var plane = doc.Views.ActiveView.ActiveViewport.ConstructionPlane();
var lines = new List<Line>();
var get = new GetPoint();
get.SetCommandPrompt("Enter");
get.PermitObjectSnap(true);
get.PermitOrthoSnap(true);
get.DynamicDraw += (s, e) =>
{
lines.Clear();
var vecX = e.CurrentPoint - basePoint;
var vecY = Vector3d.CrossProduct(plane.ZAxis, vecX);
var pln = new Plane(e.CurrentPoint, vecY, plane.ZAxis);
foreach (var item in grips)
{
var p = pln.ClosestPoint(item.CurrentLocation);
var line = new Line(item.CurrentLocation, p);
e.Display.DrawLine(line, get.DynamicDrawColor);
lines.Add(line);
}
};
get.Get();
if (get.CommandResult() != Result.Success)
{
doc.Views.ActiveView.ActiveViewport.DisplayGrips(false, type);
return get.CommandResult();
}
foreach (var item in lines)
{
doc.Objects.AddLine(item);
}
doc.Views.Redraw();
return Result.Success;
}
thanks