How do I determine the boundaries of a box enclosing all the entities?

1,167 views
Skip to first unread message

Zythyr

unread,
May 22, 2016, 2:40:40 PM5/22/16
to python-ezdxf
I have a drawing created in AutoCAD with various entities (shapes, polygon, lines, etc...). I am using Python and ezdxf to read the data from the DXF file. 

I want to determine the boundary of the modelspace in my DXF file. What I mean is that I want to determine the coordinates of the a box that would enclose all the entities in the DXF file. Attached is an an example of what I am trying to do. 


boundaries of model space.png

Manfred Moitzi

unread,
May 22, 2016, 11:36:19 PM5/22/16
to python-ezdxf
1. ezdxf is NOT a CAD application, it is just an interface to the DXF format and 2. finding the bounding box is not as easy as it seems, TEXT depends
on the used font, SPLINES and ARCS have to be rendered to get their boundaries and at last block references (INSERT) can be scaled (different in x, y, z),
rotated and can contain other block references, and I'm sure there are other issues to which I haven't thought of.

This is truly a job for a CAD application which interprets the DXF format.

In your example you have to render the ELLIPSE entity to get it's bounding box. For CIRCLE, LINES and POLYLINES finding the bounding 
box is trivial, at last merge all bounding boxes. If the extrusion vector of some entities is different to (0, 0, 1) you handle 3D entities and 
and it gets more complicated.

Best regards,
Manfred

Zythyr

unread,
May 24, 2016, 12:17:04 PM5/24/16
to python-ezdxf
Manfred, 
Thank you for your reply. I can understand where you're coming from. I guess I would have to compute the bounding box in AutoCAD itself instead of using ezdxf. 
Thanks, 
Z
Reply all
Reply to author
Forward
0 new messages