Hi,
Editor.GetCorner displays a rectangular rubberband which is always parallel to the window sides.
AutoCAD draws the rectangles parallel to the X and Y axis of the current UCS.
So, with an UCS which X and Y axis are not parallel to the window, the rubberband will be different from the rectangle.
Try this:
[CommandMethod("DRAWRECT")]
public void DrawRectangle()
{
var doc = AcAp.DocumentManager.MdiActiveDocument;
var db = doc.Database;
var ed = doc.Editor;
var ppr = ed.GetPoint("\nFirst corner: ");
if (ppr.Status != PromptStatus.OK)
return;
var pt1 = ppr.Value;
ppr = ed.GetCorner("\nOpposite corner: ", pt1);
if (ppr.Status != PromptStatus.OK)
return;
var pt2 = ppr.Value;
double x1 = pt1.X;
double y1 = pt1.Y;
double x2 = pt2.X;
double y2 = pt2.Y;
using (var tr = db.TransactionManager.StartTransaction())
{
var pline = new Polyline(4);
pline.AddVertexAt(0, new Point2d(x1, y1), 0.0, 0.0, 0.0);
pline.AddVertexAt(1, new Point2d(x2, y1), 0.0, 0.0, 0.0);
pline.AddVertexAt(2, new Point2d(x2, y2), 0.0, 0.0, 0.0);
pline.AddVertexAt(3, new Point2d(x1, y2), 0.0, 0.0, 0.0);
pline.Closed = true;
pline.TransformBy(ed.CurrentUserCoordinateSystem);
var curSpace = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
curSpace.AppendEntity(pline);
tr.AddNewlyCreatedDBObject(pline, true);
tr.Commit();
}
}
To be closer to the AutoCAD RECTANG command, you should use a Jig, but it is a more complex task.