1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
[CommandMethod("ScreenExtents")] public void ScreenExtents() { Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor; Point2d screenSize = (Point2d)Application.GetSystemVariable("SCREENSIZE"); System.Drawing.Point upperLeft = new System.Drawing.Point(0, 0); System.Drawing.Point lowerRight = new System.Drawing.Point((int)screenSize.X,(int)screenSize.Y); Point3d upperLeftWorld = ed.PointToWorld(upperLeft, 0);
Point3d lowerRightWorld = ed.PointToWorld(lowerRight, 0); using (Transaction Tx = db.TransactionManager.StartTransaction()) {
Line line = new Line(upperLeftWorld, lowerRightWorld);
BlockTableRecord btr = Tx.GetObject(db.CurrentSpaceId, OpenMode.ForWrite) as BlockTableRecord; btr.AppendEntity(line);
Tx.AddNewlyCreatedDBObject(line, true); Tx.Commit(); } }
|