Export (a lot of) curves to svg

Hello everybody,

I am trying to export a large number of curves to a svg-file.
I am using the “Viewport to SVG” Add-On and I am able to export one curve.

But how can I export all curves within my 3D view at the same time into one svg-file?
Select all curves and use the “Export SVG” Button does not work :frowning:

Best regards,
LF1900

If nobody knows an option to export my 3D view to an svg file, does anybody know an option to create a screenshot with a very good quality, instead? The capture tools in blender lead to a quite poor graphic quality and I would like to present some results of my blender work (which are mainly curves in the 3D view) and therefore I need some real good graphics.

Hope Zeffi will excuse my messing up his code…



Each object is it’s own group in svg, LocRotScale and modifiers need to be applied before export.

Thank you very much, eppo!

When I export the “standard blender cube”, it works fine.
But when I export my own cube - attached as zip/stl-file - my svg export seems to be empty. Any idea what could be the reason?

Furthermore, it seems that only one object is exported (“Active object is: …”).
How can I export all my objects (cube + additional curves) at the same time?

Best regards,
LF1900

Attachments

Cube 10x10x10.zip (288 Bytes)

Your hint concerning Alt-C to convert curves to the mesh seems to be a very good one, because now the script tries to render all objects. Unfortunately I get an error message in the console - “NoneType” object has no attribute x (see attachement).

When I open the attached svg-File (which was created when only my cube was selected) with CorelDraw… I see nothing. Can you see my cube?

Attachments

svg_output.zip (674 Bytes)


Yes i am able to open file, Inkscape had no problems opening it.



Nevertheless here is another version of the script with slightly changed header info. Maybe helps CD recognize file type, i can not test this unfortunately.

Thanks a lot eppo, but CD doens´t like it at all…
Well, it doesn´t matter, I can use inkscape as well…

But what does matter is that the script still crashes with the ‘NoneType’ Error which you can see in the screenshot.
Do you have an idea what could be the reason for this? Too many objects to export?


Could you make available cube svg from CDR?

For me only time when i see this error is if objects had not applied scale. I ordered python to make a confused face, account for such an error and continue to fill in SVG. Test of 5000 spawned Cubes did some stress on Inkscape ;).

Hey eppo,

I am…

… happy, because now it works - thanks a lot!

… confused, because it does only work, when I keep my blender file saved on my desktop (I always save “work in progress” on my desktop). When I move the blender file to another path, the script itself still works and creates a svg file, but inkscape doesn´t show any contents. No matter where I save my blender file and no matter to which path I save my svg file. (I don´t need a solution for this issue because I can live with a file on my desktop, but perhaps you are interested in this issue!?)

… confused again by your question: “…available cube svg from CDR?” I do not have a svg from CDR, only my svg from Blender - created by your scirpt. Please let me knwo what you need.

LF1900

By “cube svg from CDR” i did actually mean draw simple square shape in CorelDraw and save as an svg file. Hope i could peak inside and see what for CDR might not like files which are perfectly read by Inkscape.

What OS are you on? Win, Mac, nix?
I see about file saving part; hopefully this wont be an issue. Meanwhile if you open blender’s console window, script does print path where file will be saved. Maybe you’re looking at the different file script writes data to. Have you tried to click on folder icon and change path/filename manually?

Hello eppo,

here comes your CDR cube.svg

But as I said before: For me it is no problem to use inkscape and start from my desktop, so don´t take to much effort into this problem. I am using Win7 by the way…

Best regards,
LF1900

Attachments

cube.zip (888 Bytes)

Thanks for a file!
Did have a look inside however could not immediately see why would CDR refuse exports from Blender. Inkscape does not have a problem reading this and in order to solve CDR’s problem i would need to experiment throwing different ‘unrelated’ bits into exported files; since i don’t have CDR, well, this stays as is.
I’ve tried to use script on nix and win xp pcs - export was created on both OSes. Default settings for save might fail but if you click the file manager icon and set path/file name explicitly there were no problems saving/reading files so that i can’t figure what exactly goes wrong in your case.
If some of by-passers here had some feedback, maybe that could help somehow ;).

Again, all objects need to be scale, rotation applied. If there are errors (likely caused by not having this done) random segments could be ignored on export.
If location is not applied exported objects are stacked in the center of exported image.

Cheers, over and out for now.

eppo, you are the best.

LF1900, have you tried using Freestyle? If all you want to do is show off your work, freestyle can produce beautiful results.

There’s also a Freestyle SVG Export option that might be useful.

That said, eppo really is the best, so if you can get his stuff to work for you, go for it.

Freestyle has (had?) it’s quirks. Last time on a lot of lines it would chew up all my ram and swap space and then graciously crash.
But there are alternatives - see #5.

Meanwhile this will preserve Cycles diffuse color if there is one assigned to the object. If not - guess what, it will be drawn in black ;).

Hi eppo,

thanks for you efforts.
What exactly do you mean by: “Again, all objects need to be scale, rotation applied.”

Best regards,
LF1900

Scaling, rotating, moving objects in Object mode does not reflect on actual object’s mesh which is checked while being converted to svg.
As a result svg might look quite different from what’s visible in a viewport.
Not applied objects scales usually cause problems with how modifiers or textures work/look.

To get ‘proper’ scene view in exported svg you need to select objects and Ctrl-a, Apply-> Location, Rotation, Scale.

Ctrl-a, Apply Location will move object’s Origin to the center of coordinates - you’d need to deal with this later by moving Origins back to where they were if there’s more modeling work to do.

You can check this by moving, scaling and rotating some Cubes around in Object mode and then exporting to svg; apply transforms and export again to compare.

Applying LocRotScale, exporting svg and then bringing scene back to where it was could be scripted of course… However i assume one can Ctrl-a transforms, export svg and File-Open same file again…