Get extents from a drawing using a database without opening a drawing

In the AutoCAD.NET API, when you open a drawing, you can get extents using the EXTMAX and EXTMIN environment variables. However, these variables do not give the correct values โ€‹โ€‹unless you have an open drawing. How do you get the same extents without opening a drawing (AKA using a database)?

+3
source share
1 answer

I went through Autodesk discussion groups and found an answer from Tony Tanzillo.

http://forums.autodesk.com/t5/NET/Zoom-Extents-on-new-Database/mp/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;
+5
source

Source: https://habr.com/ru/post/1770402/


All Articles