[CommandMethod("TEST_0401")]
public void Select2dExtent()
{
var doc = AcadApp.DocumentManager.MdiActiveDocument;
var ed = doc.Editor;
Point3d bp = default, cp = default, minPt = default, maxPt = default;
PromptPointResult pointResult = default;
// Select BasePoint
PromptPointOptions promptPointOptions =
new PromptPointOptions
("Select BasePoint for Rectangle") {
AllowArbitraryInput = true,
AllowNone = false,
LimitsChecked = true
};
pointResult = ed.GetPoint(promptPointOptions);
if (pointResult.Status == PromptStatus.OK)
bp = pointResult.Value;
else
{
ed.WriteMessage("\n Invalid Base Point Selection.");
return;
}
// Select Opposite Corner
PromptCornerOptions cornerOptions =
new PromptCornerOptions
("Select opposite corner", bp
) {
AllowArbitraryInput = true,
AllowNone = false,
LimitsChecked = true,
UseDashedLine = true
};
pointResult = ed.GetCorner(cornerOptions);
if (pointResult.Status == PromptStatus.OK)
cp = pointResult.Value;
else
{
ed.WriteMessage("\n Invalid Corner Point Selection.");
return;
}
ed.WriteMessage($"\nbp: {bp} \ncp: {cp}");
Point3dCollection point3dCollection
= new Point3dCollection
{ bp,
cp
};
Extents3d extents
= new Extents3d
(); foreach (Point3d point in point3dCollection)
extents.AddPoint(point);
minPt = extents.MinPoint;
maxPt = extents.MaxPoint;
ed.WriteMessage(
$"\nminPt: {Convert2d(minPt)} " +
$"\nmaxPt: {Convert2d(maxPt)}");
}
public static Point2d Convert2d(Point3d pt)
{
return new Point2d
(pt
.X, pt
.Y); }