Open trapgate opened 3 years ago
I think this is caused by a version mismatch for the svg_path
package dependency. The repository is still using version 2.2 of svg_path
(3d/scripts/requirements.txt), which doesn't have this issue.
Looking at the project history on PyPi it looks like support for Move
commands was added in version 3.0. I'm not sure if there are any other reasons to stay on the old package, but you'd have to update the dependency version in your PR for the build to complete.
I think that's right - it makes some sense that without move support, the svg library would probably have been translating Close
into Line
, though I'd have to trace through the code with the old library installed to be sure.
I took a slightly nonstandard route to get here - I ported everything to python3, and completely forgot to check for the older version of svg.path once I had that working.
The code that removes duplicate lines from svg paths in
3d/scripts/svg_processor.py
has a problem. When I rungenerate_2d.py
, the output incombined.svg
looks like this:The diagonal lines cutting across some of the parts are caused by trimming lines immediately preceding
Close
elements from some of the paths. When the svg.path package parses an svg path and returns a representation,Close
elements are returned with a start and end point, just like aLine
element. But the XML representation ofClose
is just aZ
, which is interpreted by svg editors as, 'draw a line from the current point to the location of the most recentMove
element in this path.' As a result, even though the path removal code was updating the start or end points for theClose
element after it removed the preceding line, those points were just being ignored when svg.path regenerated the XML for the altered path.I have a fix for this problem, which is just to turn all
Close
elements intoLine
elements when processing paths. The resulting .svg files have worked fine in both svg editors (inkscape and Affinity Design, at least), and when used to drive my Glowforge. I'll submit a PR with those changes in a few minutes.