-
-
Notifications
You must be signed in to change notification settings - Fork 99
Description
I noticed that in KiCAD V9, the way a no-stroke and no-fill are generated changed from previous versions, and how some silk are generated, which breaks the final drawing.
In previous version, the styles fill-opacity:0.0 if a path is to not be filled, but in recent version this has changed to fill: none. This is removed in the generation by the function strip_style_svg(), which is meant to remove the stroke attribute to apply styling.
Regarding strokes, newer version also generate stroke: none and draws out any stroked path, whereas older versions drew individual lines and set some stroke. Below are examples of such, the same KiCAD, one generated two years ago, and the other generated while I was typing this PR.
My new image above was with a hacked fix, this is what it looks like without it

I wanted to raise this issue in case anybody else comes across it in the future. For now the following patch should fix this specific issue, but I will see if there is a better way, and create a PR for it if so.
diff --git a/pcbdraw/plot.py b/pcbdraw/plot.py
index fceb6b6..8204b23 100644
--- a/pcbdraw/plot.py
+++ b/pcbdraw/plot.py
@@ -388,8 +388,13 @@ def strip_style_svg(root: etree.Element, keys: List[str], forbidden_colors: List
stroke = styles.get("stroke", "").lower()
if fill in forbidden_colors or stroke in forbidden_colors:
elements_to_remove.append(el)
+ styles = {key: val for key, val in styles.items() if key not in keys}
+ if stroke == 'none':
+ styles['stroke'] = 'none'
+ if fill == 'none':
+ styles['fill'] = 'none'
el.attrib["style"] = ";" \
- .join([f"{key}: {val}" for key, val in styles.items() if key not in keys]) \
+ .join([f"{key}: {val}" for key, val in styles.items()]) \
.replace(" ", " ") \
.strip()
for el in elements_to_remove:
