Several developers have been asking this question recently through ADN support, on how to retrieve the extents of the AutoCAD model window in world coordinates.
There are several approaches to achieve that, but the easiest according to me, is to rely on the “SCREENSIZE” system variable.
Here is the C# code:
public void ScreenExtents()
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
Point2d screenSize = (Point2d)
System.Drawing.Point upperLeft = new System.Drawing.Point(0, 0);
System.Drawing.Point lowerRight = new System.Drawing.Point(
Point3d upperLeftWorld = ed.PointToWorld(upperLeft, 0);
Point3d lowerRightWorld = ed.PointToWorld(lowerRight, 0);
using (Transaction Tx = db.TransactionManager.StartTransaction())
//Draws a line to visualize result...
Line line = new Line(upperLeftWorld, lowerRightWorld);
BlockTableRecord btr = Tx.GetObject(