-2

I have a dxf drawing and I want to find the number of regions which have closed loops. For Example: The below picture has two closed loops. I want to detect that this drawing has 2 closed loops.

I am using ezdxf library in Python. If I use the inherent function (.isclosed) it will check for each entity individually. In the below figure, the inner loop consists of multiple entities (lines and curves) and this fails to get detected. How to overcome this issue i.e it should detect closed loops irrespective of the number of entities.

Two Bounded Regions

James Z
  • 12,209
  • 10
  • 24
  • 44
user3608646
  • 13
  • 1
  • 8
  • Try something like this and see what it returns, this should show you what you are looking for https://ezdxf.mozman.at/docs/tutorials/getting_data.html#iterate-over-dxf-entities-of-a-layout – Joe Apr 03 '20 at 19:22
  • Or https://ezdxf.mozman.at/docs/tutorials/getting_data.html#entity-queries with `Where * means all DXF entities` – Joe Apr 03 '20 at 19:24

1 Answers1

1

In principle, the graphical primitives that define the region outlines have endpoints in common (possibly to a slight numerical error).

Either they are already chained in the dxf file, and you just have to check proper closure, or they are stored randomly. In this case, you can find the endpoint matchings and reconstruct the chains.