SVG output script


(liero) #1

Hi, here is a script I’ve been playing with for a while: the idea is to get some quick vector output from Blender to feed Inkscape. It is not meant to be a NPR solution -as Freestyle will be- but you can still do some basic tricks. And it is pretty useful for simple shapes and so… I also tried to add a few abstract and geometric stuff into the mix.

Script will export current viewport -think a screen capture application- to a SVG file. Works with meshes and curves. I suggest you to open the svg file in a browser -Opera is very fast- and use it as a viewer while you play with settings. SVG code can also be edited inside the browser.

script: https://www.dropbox.com/s/93xguzky732ajy8/export_svg.py?dl=1


the SVG vector files for the picture above: https://www.dropbox.com/s/cnm4krfprorcv43/SVG.zip?dl=1

A couple of tips:

  • limit the amount of exported geometry to get a faster export, but also to get different looks…

  • use viewport to frame the objects, you can go ortho mode or edit lens value, check distortions

  • ‘add to svg’ allows to append shapes to your svg, something like a ‘multiple exposure’ :stuck_out_tongue:

    here some test done with a previous version of script on a model from project london arizona: https://www.dropbox.com/s/emo7hbcqax3odqv/arizonapruebas.jpg?dl=1

edit: added some help here: https://www.dropbox.com/s/mbp3z4l4hwyg86n/settings.jpg?dl=1

cheers


(swmo) #2

Very interesting. Thank you!


(matali) #3

thanks a lot Liero :slight_smile:


(vklidu) #4

Wow !!! What a day :slight_smile: would be hard to wait until Monday to test it. Image looks awesome. Thank you man.


(kgeogeo) #5

Just Wow!!!


(Benkei) #6

Great! That’s a really useful add-on! Thanks so much.
I am eager to see the next major step.
Svg animation?


(tungee) #7

Great as Always! Hope Campell doesnt break this Addon too!
Edit: This is a Killer Addon!!!
Such great possibilities!


(Safetyman) #8

Which version of Blender is this for? I can’t seem to get it to work with v2.66.



(ejnaren) #9

@liero: No words man, no words! I am going to test this right now!

FOLLOWUP: It works great! I could not get it to export curves but the rest works very very very good!
It is a very well done addon! All the options makes it so powerful.
It is amazing.

Question: I see you use a scale option. How does the size of the resulting SVG objects compare to the size of the object? Say if I export a box where each edge is 10 cm in ortho mode. Is there a way to get the SVG edges to be 10cm in the .svg file?

Congrats again on this great tool! I will have to look through the source soon.


(Atom) #10

@safetyman: Try specifying a folder on your desktop for output. If that does not work turn off Relative Path. I had a similar crash when I tried it out. But Absolute Pathing to an existing folder that you have permissions too will work.


(Safetyman) #11

@Atom – thanks that worked. I’ll have to play around with the settings, but it looks to work really well. You also must select an object or objects for it to render anything.

@Liero – thanks for creating this. I’ve been waiting for something like this for a long time. Great job!


(alan.zirpoli) #12

i was waiting for something like this too. Can you share the setting of the different example you post here?


(liero) #13

thanks for the response guys, good to see you found this useful!

@safetyman sorry for the path problem, that needs to be properly coded
@ejnaren I meant beveled curves, but added a simplistic way to render 3D un-beveled curves as paths; and pixels are just screen pixels atm, the scale works by multiplying this values… as a quick hack I could add an option to calculate scale -just ortho mode-
@alan.zirpoli will try to add some way of storing and retrieving the settings from svg file, then I could upload some examples

main issues are related to z ordering of faces and objects, also my math / coding skills are pretty basic so things could surely run faster and better

been doing some fixes, so maybe download the script again…


(ejnaren) #14

@liero: I cant tell you how useful that it already is!
I have been researching which is the easiest way to get renders in scale from blender. I am an architect so it is very useful.
By being bale to export drawings directly from blender you have essentially opened Blender for me to use as my main modeling app.

The ortho scale option might be better to add as an alternative addon? Some times you want to get your normal renders out in a certain scale as well. The render to print addon helps though:)

Anyway I just wanted to give you an idea:
If the viewport / camera is in ortho mode. Then curves and handles are distorted uniformly. Meaning that even though the curve is 3D and the viewport is rotated the handles as seen in the viewport shapes the curve as seen in the viewport.

I have traced a simple bezier inkscape over a screenshot from blender.
ie: ORTHO:



Export function in other app all subdivide the curve making it into hundreds of segments to approximate it.
I would be cool if the curve could be exported as is. Only works in ortho mode though: PERSPECTIVE:


I dont know to much about curve math in perspective distortion but it seems the handles are the same angle at the viewport but needs some scaling factor.

I am sorry for this looong post but you have made my week. Im gonna let go now and go to bed.
Thanks for the work man. It will work wonders for drawing sections of buildings with the cross section script I ported some time ago.


(dphantom) #15

Oh man this one hell of a useful addon.
God knows I have dreamt about something like this, think of the possibilities!
This is gonna be great for exporting orthographic views elevations plans etc…

So many thanks!! Gonna give it a try soon


(84d) #16

This is great. Thank You so much, You made my day!
i cant wait to try this.


(liero) #17

added a fixed scale option when in ortho mode -in fact this script started as orthogonal only- but I guess the right solution would be to implement camera support; will think on the curves idea too…

@dphantom and @84d don’t get too excited as it can get a bit tricky to get nice results… share anything cool you make :wink:


(3Duaun) #18

WOW! great work on the various styles


(eXKR) #19

Awesome!!!

Just one thing: is it possible that you add the parameter configuration for all the examples? that way it would be much easier to get an overall idea of “what each parameter is used for”…
Thanks, great work.


(alan.zirpoli) #20

That’s what I’ve meant too!