Skip to content

Commit ce8e187

Browse files
authored
Include all path collections (#9)
* Include all path collections
1 parent 160169f commit ce8e187

File tree

3 files changed

+41
-35
lines changed

3 files changed

+41
-35
lines changed

CHANGES.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Changes
22

3+
## Version 0.6.0
4+
5+
_2024-12-12_
6+
7+
Fix:
8+
9+
- Include support for all path collections
10+
311
## Version 0.5.0
412

513
_2024-12-12_

mpldxf/backend_dxf.py

Lines changed: 32 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -167,32 +167,33 @@ def _draw_mpl_lwpoly(self, gc, path, transform, obj):
167167

168168
# clip the polygon if clip rectangle present
169169

170-
if isinstance(vertices[0][0], float or np.float64):
171-
vertices = self._clip_mpl(gc, vertices, obj=obj)
172-
173-
else:
174-
vertices = [self._clip_mpl(gc, points, obj=obj) for points in vertices]
170+
if len(vertices) > 0:
171+
if isinstance(vertices[0][0], float or np.float64):
172+
vertices = self._clip_mpl(gc, vertices, obj=obj)
175173

176-
# if vertices.
177-
if len(vertices) == 0:
178-
entity = None
174+
else:
175+
vertices = [self._clip_mpl(gc, points, obj=obj) for points in vertices]
179176

180-
else:
181-
if isinstance(vertices[0][0], float or np.float64):
182-
if vertices[0][0] != 0:
183-
entity = self.modelspace.add_lwpolyline(
184-
points=vertices, close=False, dxfattribs=dxfattribs
185-
) # set close to false because it broke some arrows
186-
else:
187-
entity = None
177+
# if vertices.
178+
if len(vertices) == 0:
179+
entity = None
188180

189181
else:
190-
entity = [
191-
self.modelspace.add_lwpolyline(
192-
points=points, close=False, dxfattribs=dxfattribs
193-
)
194-
for points in vertices
195-
] # set close to false because it broke some arrows
182+
if isinstance(vertices[0][0], float or np.float64):
183+
if vertices[0][0] != 0:
184+
entity = self.modelspace.add_lwpolyline(
185+
points=vertices, close=False, dxfattribs=dxfattribs
186+
) # set close to false because it broke some arrows
187+
else:
188+
entity = None
189+
190+
else:
191+
entity = [
192+
self.modelspace.add_lwpolyline(
193+
points=points, close=False, dxfattribs=dxfattribs
194+
)
195+
for points in vertices
196+
] # set close to false because it broke some arrows
196197
return entity
197198

198199
def _draw_mpl_line2d(self, gc, path, transform):
@@ -311,7 +312,7 @@ def draw_path_collection(
311312
paths,
312313
all_transforms,
313314
offsets,
314-
offsetTrans,
315+
offset_trans,
315316
facecolors,
316317
edgecolors,
317318
linewidths,
@@ -320,17 +321,14 @@ def draw_path_collection(
320321
urls,
321322
offset_position,
322323
):
323-
if self._groupd[-1] == "PolyCollection":
324-
# Behandle PolyCollection som en samling av 'patch'-objekter
325-
for path in paths:
326-
# Kombiner master_transform med path_transform for hver path
327-
combined_transform = master_transform
328-
# Her kan du velge å bruke eller tilpasse rgbFace basert på facecolors, hvis det er relevant
329-
if facecolors.size:
330-
rgbFace = facecolors[0] if facecolors is not None else None
331-
else:
332-
rgbFace = None
333-
self._draw_mpl_patch(gc, path, combined_transform, rgbFace)
324+
for path in paths:
325+
combined_transform = master_transform
326+
if facecolors.size:
327+
rgbFace = facecolors[0] if facecolors is not None else None
328+
else:
329+
rgbFace = None
330+
# Draw each path as a filled patch
331+
self._draw_mpl_patch(gc, path, combined_transform, rgbFace=rgbFace)
334332

335333
def draw_path(self, gc, path, transform, rgbFace=None):
336334
# print('\nEntered ###DRAW_PATH###')

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "mpldxf"
3-
version = "0.5.0"
3+
version = "0.6.0"
44
description = "A fork of mpldxf - a matplotlib backend to write DXF drawings. Modified by NGI to handle geotechnical plots"
55
authors = ["David Kent",
66
"Jon-Michael Josefsen <[email protected]>",

0 commit comments

Comments
 (0)