SVG Import
SVG -> Geometry -> SVG.
For export see #197.
Comments (32)
-
reporter -
reporter Basic support for importing SVG. Via shell only at this time. See issue
#179.→ <<cset fdf809774f56>>
-
reporter Try the feature in the development version by opening the shell and running:
import_svg tests/svg/drawing.svg -outname mysvg
The SVG file is included in the repository. It was created using Inkscape 0.48.4-3ubuntu2.
-
reporter Added SVG importing support to the GUI menu. See issue
#179.→ <<cset d3ed12e5def9>>
-
I installed svg.path via pip and then I was able to import the example. But with a .svg of my own made in Inkscape 0.91, FlatCam refused to load it.!
-
reporter The error you are getting is because there was no support for units and your file was using something like "273mm" somewhere. I just added support for parsing the units, but to ignore them (5 minutes ago). For best results right now, make sure all your units are "px". In Inkscape, got to File -> Document Properties and set default units and those in "Custom size" to "px".
"px" in SVG are known as "User units" and is equivalent to having no units. To use anything different we would have to specify a DPI quantity to relate pixels to absolute units. It's and SVG thing.
Please play around with it now and tell me what you think.
-
Yes, I had the document defined in a A4 size, in mm, as I find it useful in my applications.
I tried again and it is working for linear shapes (triangle, star, square) but it is not showing an ellipse. "Unknown kind: ellipse"
But if I try to make a circle it will load nothing at all.
-
reporter Yes! No ellipse support yet!
I can add that easily, but you are welcome to try it yourself. This is all in the file
svgparse.py
. -
Well, I do not have knowledge of object based programming (what programming I do is C for microcontrollers). But I will try :)
-
reporter You don't have to write any code yourself. You can look up the specs for SVG ellipses and post a formula here on how to calculate the points.
Or you can keep finding bugs! Any help is appreciated!
-
Something like the second answer from here? http://stackoverflow.com/questions/5737975/circle-drawing-with-svgs-arc-path/10477334#10477334 or maybe: http://www.mathopenref.com/coordcirclealgorithm.html
-
reporter More of a combination of this:
http://www.w3.org/TR/SVG/shapes.html#EllipseElement
and this:
http://mathworld.wolfram.com/Ellipse.html
We would like to have a formula for
x
andy
as a function of a parametert
from 0 to 1 and the parameters explained in the first link, such that for any t you get a point on the ellipse and as t increases/decreases you go around the ellipse. -
LE: Found this: http://central.scipy.org/item/23/2/plot-an-ellipse
From Wikipedia: https://en.wikipedia.org/wiki/Ellipse
x = cx + rx * cos (2*PI*t)* cos (2*PI*phi) - ry * sin (2*PI*t) * sin (2*PI*phi) y = cy + rx * cos (2*PI*t) * sin (2*PI*phi) + ry * sin (2*PI*t) * cos (2*PI*phi) t = [0 ... 1] phi = [0 ... 1] and it describes the angle between the X-axis and the major axis of the ellipse.
-
reporter Thanks. I will try to code it in this weekend!
-
Thank you! Merry Christmas!
-
reporter Support for ellipse has been added in b46d2b5.
-
reporter Pending SVG features are:
rect
with rounded cornersline
polyline
polygon
-
reporter Only
rect
with rounded corners is pending. -
This feature would really save my day... looking forward to it and I can live without round rect
-
reporter It's already available in the repository. Don't count on a release any time soon though.
See the very minimal docs here: https://bitbucket.org/jpcgt/flatcam/wiki/betadocs
-
:-( I'm a Windows user (yeah, I know....) and I don't know how to build the exe, I'm a Java/JS developer with some limited C/C++ knowledge (Arduino stuff)...
Can you help me out?
BTW, if Windows XP is still supported, I can report an error on that platform...
-
reporter You can still install the source on Windows by hand: http://flatcam.org/manual/installation.html#manual-installation
Please send me a message directly and I can help you there.
-
I've found the problem, it's the additional space at the end of the points sequence. I believe the Python function to trim a string is
strip()
, which I believe should be appended to line 349:for match in re.finditer(r'(\s*,\s*)|(\s+)', ptliststr):
I belive should become
for match in re.finditer(r'(\s*,\s*)|(\s+)', ptliststr.strip()):
but I've no experience with python, so I'll let you decide if that's the correct way to do it ;)
-
reporter - edited description
- changed title to SVG Import
For export see #197.
-
reporter I would like to close this. Has anybody encountered any problems importing SVG?
-
I plan to run a few tests during the weekend, I'll let you know
-
reporter - changed status to resolved
No known problems remain.
-
SVG import seems broken for me. I am using recent git snapshot. here is an example. I've tried various svg's - generated by eagle, potrace and inkscape, and all of them do have problems.
-
- attached 12f675_atx_24V_board_drawable.svg
this is the source svg file for reference/testing
-
reporter Issue
#237was marked as a duplicate of this issue. -
reporter @curious_pl , I understand that you did not get what you expected when you imported the SVG into FlatCAM, but it's not totally unexpected:
- You are importing into a Geometry Object, which is just made of lines. So everything with a solid interior in the SVG is not going to "look" the same.
- It seems you are interested in treating the SVG as a Gerber, i.e. a collection of solid areas. I suggest you try the shell command "import_svg" with the "-type gerber" option, which should import it into a Gerber Object instead.
The SVG import feature may never be perfect since what you see on the screen in a program like Inkscape is the "rendered" version of the SVG. You may see a black/solid region on the screen, but it can be made of all sorts of garbage. Since it's all black, it looks as a single solid even though it is not. FlatCAM will correctly understand the lines, without their thickness, and the perimeters of polygons, circles and ellipses.
I would be willing to reopen this issue, but there must be a clear consensus about what is broken and what is the expected behavior.
-
tried to import using -type gerber, and this produces error like that, and no import at all :
"import_svg -gerber /home/curious/Desktop/obiekty3d/liquid/tests/nnn_190.svg"
import_svg -type gerber /home/curious/Desktop/obiekty3d/liquid/tests/nnn_190.svg Object (gerber) created: nnn_190.svg Opened: /home/curious/Desktop/obiekty3d/liquid/tests/nnn_190.svg ERROR: list indices must be integers, not str Python traceback: <type 'exceptions.TypeError'> File "/home/curious/Desktop/flatcam/flatcam/tclCommands/TclCommand.py", line 373, in wait_signal > raise ex[0] File "/usr/lib64/python2.7/contextlib.py", line 24, in exit > self.gen.next() File "/home/curious/Desktop/flatcam/flatcam/tclCommands/TclCommand.py", line 404, in execute_wrapper > self.app.worker_task.emit({'fcn': self.execute_call, 'params': [args, unnamed_args]}) while executing "import_svg -type gerber /home/curious/Desktop/obiekty3d/liquid/tests/nnn_190.svg"
- Log in to comment
Libraries for reading:
Libraries for writing: