SebKuzminsky / pycam

Other
340 stars 98 forks source link

import SVG files directly #119

Closed SebKuzminsky closed 6 years ago

SebKuzminsky commented 6 years ago

Currently PyCAM does not open SVG files directly. SVG files are first converted to EPS by shelling out to inkscape, then the EPS is converted to DXF using pstoedit, then PyCAM reads the DXF file. This is inefficient and error prone (for example #118).

It would be better to teach Importers.SVGImporter to parse SVG files and convert them directly to PyCAM's internal Geometry representation.

There are several python SVG libraries packaged for Debian Stretch we could investigate to see if they're appropriate for this:

sumpfralle commented 6 years ago

Indeed, this would be a nice improvement!

One nice side-effect of the SVG->EPS->DXF conversion was the reduction to basic geometry objects (lines, circles, arcs). I do not know the SVG specification, but I could imagine, that it allows more (complicated) geometry primitives. (just wild guessing) Anyway: the conversion really needs to go away.

SebKuzminsky commented 6 years ago

SVG does have additional, more complicated geometric primitives (quadratic and cubic bezier splines), but for now we can have it perform linear interpolation of all non-Line object, just like DXFImport does with arcs and circles.

sumpfralle commented 6 years ago

I am looking into "python3-svg.path" for now. It seems to be simple (interpreting only simple path types), but this should be suitable for us. The python3-svg.path package is orphaned right now in Debian, but upstream looks active, thus I can imagine, that I will help maintaining that package. Whichever option we pick: we will probably not be able to support all the complexity of the svg specification (e.g. transformations), but I guess, we can live with that.

sumpfralle commented 6 years ago

Implemented in f29c90a.