Search code examples
pythonvertexdxf

how to find a dxf entity is inside another entity?


3d letter from DXF File

In the image there is a 3d letter O from dxf file. O represented as two rounds.so there is two entity.

How can i detect one entity is inside another (in case of o,how to know small round is inside big round)?


Solution

  • In this case, calculate the bounding box around both entities. This has the form of a tuple, say (xmin, xmax, ymin, ymax). You can think of this as a box with sides parallel to the x- and y-axes that surrounds the entity.

    If both the x-values from the first bounding box are in between the xmin and xmax of the second bounding box, and the same goes for the y-values, the first bounding box is inside the second one.

    Note that this technique is an approximation. It is possible to create entities that overlap while their bounding boxes don't intersect.