File tree 3 files changed +19
-7
lines changed
src/sectionproperties/pre
3 files changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -2514,16 +2514,24 @@ def load_dxf(
2514
2514
my_dxf .cleanup ()
2515
2515
2516
2516
polygons = my_dxf .polygons
2517
- new_polygons = c2s .utils .find_holes (polygons )
2517
+ new_polygons = c2s .utils .filter_polygons (polygons )
2518
2518
2519
- if isinstance (new_polygons , MultiPolygon ):
2520
- return CompoundGeometry (new_polygons )
2521
- elif isinstance (new_polygons , Polygon ): # pyright: ignore [reportUnnecessaryIsInstance]
2522
- return Geometry (new_polygons )
2523
- else :
2519
+ # ensure list length > 0
2520
+ if len (new_polygons ) == 0 :
2524
2521
msg = f"No shapely.Polygon objects found in file: { dxf_filepath } "
2525
2522
raise RuntimeError (msg )
2526
2523
2524
+ # ensure only Polygons are generated
2525
+ for poly in new_polygons :
2526
+ if not isinstance (poly , Polygon ): # pyright: ignore [reportUnnecessaryIsInstance]
2527
+ msg = f"Not all objects found in file: { dxf_filepath } are Polygons"
2528
+ raise RuntimeError (msg )
2529
+
2530
+ if len (new_polygons ) == 1 :
2531
+ return Geometry (new_polygons [0 ])
2532
+ else :
2533
+ return CompoundGeometry (MultiPolygon (new_polygons ))
2534
+
2527
2535
2528
2536
def create_facets (
2529
2537
points_list : list [tuple [float , float ]],
Original file line number Diff line number Diff line change 1
1
from .dxf import DxfImporter
2
- from .utils import find_holes
2
+ from .utils import filter_polygons , find_holes
Original file line number Diff line number Diff line change 1
1
from shapely .geometry import Polygon
2
2
3
3
def find_holes (polygons : list [Polygon ]) -> Polygon : ...
4
+ def filter_polygons (
5
+ polygons : list [Polygon ],
6
+ filter_flag : int = ...,
7
+ ) -> list [Polygon ]: ...
You can’t perform that action at this time.
0 commit comments