In the AutoCAD .NET API, while you have a drawing open, you can get the extents using the environment variables EXTMAX and EXTMIN. However, these variables don't supply correct values when you do NOT have the drawing open. How do you get these same extents without opening the drawing (AKA using the Database)?
Asked
Active
Viewed 3,995 times
1 Answers
6
I browsed the Autodesk Discussion Groups and found the answer from Tony Tanzillo.
http://forums.autodesk.com/t5/NET/Zoom-Extents-on-new-Database/m-p/2070825/highlight/true#M8176
Here is an example:
Database database = new Database(false, true);
String drawingFilePath = @"C:\Drawings\MyDrawing.dwg";
database.ReadDwgFile(drawingFilePath, FileShare.ReadWrite, true, String.Empty);
database.UpdateExt(true);
Point3d extentsMax = database.Extmax;
Point3d extentsMin = database.Extmin;

skeletank
- 2,880
- 5
- 43
- 75
-
I hate to bring this back to life - but how exactly are you referencing objectArx dll files without autocad being open? - I thought you had to run these dll inside the COM as in a plug-in? - this is for standalones right? – Pakk Feb 06 '16 at 08:00
-
1@Pakk Using the database method to open the drawing just means opening the drawing in the back-end without it displaying anything visually in the user interface. You still have to run this code from a plugin inside AutoCAD. – skeletank Feb 08 '16 at 13:08