Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import SVG files directly #119

Closed
SebKuzminsky opened this issue Apr 26, 2018 · 4 comments
Closed

import SVG files directly #119

SebKuzminsky opened this issue Apr 26, 2018 · 4 comments

Comments

@SebKuzminsky
Copy link
Owner

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
Copy link
Collaborator

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
Copy link
Owner Author

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
Copy link
Collaborator

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 added a commit that referenced this issue Aug 20, 2018
Previously inkscape and pstoedit were chained in order to convert SVG
files to DXF and import the result. This process turned out to be error
prone (besides requiring additional dependencies):
* #118

The new implementation uses svg.path for interpreting basic SVG paths
directly in Python without calling external commands.
For now only a few SVG entities are supported (paths and rectangles).
More entities will probably follow (on demand), like circles and
simple transformations. Full SVG support would be very demanding and is
probably not worth the effort, thus it is not a design goal.
Interested users can always execute the simplication to a path on their
own (e.g. via inkscape).

Closes: #118, #119
@sumpfralle
Copy link
Collaborator

Implemented in f29c90a.

sumpfralle added a commit that referenced this issue Jul 28, 2019
Previously inkscape and pstoedit were chained in order to convert SVG
files to DXF and import the result. This process turned out to be error
prone (besides requiring additional dependencies):
* #118

The new implementation uses svg.path for interpreting basic SVG paths
directly in Python without calling external commands.
For now only a few SVG entities are supported (paths and rectangles).
More entities will probably follow (on demand), like circles and
simple transformations. Full SVG support would be very demanding and is
probably not worth the effort, thus it is not a design goal.
Interested users can always execute the simplication to a path on their
own (e.g. via inkscape).

Closes: #118, #119

(cherry picked from commit f29c90a)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants