How to convert svg > dxf from CLI?

Discussion about writing code for Inkscape.
Draftsman
Posts: 3
Joined: Thu Jul 13, 2017 2:14 am

How to convert svg > dxf from CLI?

Postby Draftsman » Thu Jul 13, 2017 2:38 am

Hi,

I would like to use Inkscape in a standalone script for svg > dxf conversion. Just like in GUI "save as dxf" - but how to do it in CLI? I found only CLI options for eps,pdf export, also verb list didn't help me. Is it even possible to use Inkscape that way?

(I want to convert svg blueprints rendered by Blender.)

Or you can suggest other svg>dxf conversion tool for linux or python if you know.

Moini
Posts: 3381
Joined: Mon Oct 05, 2015 10:44 am

Re: How to convert svg > dxf from CLI?

Postby Moini » Thu Jul 13, 2017 3:33 am

If you're on Linux, Inkscape brings ps2dxf.sh (in /share/extensions directory), which it uses in its own extension for export to version 12 of dxf. It appears to take an eps file and convert it to dxf. Never tried, but one possible option, if you export to eps via cli, then feed the result into the sh script.
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)

Draftsman
Posts: 3
Joined: Thu Jul 13, 2017 2:14 am

Re: How to convert svg > dxf from CLI?

Postby Draftsman » Sat Jul 15, 2017 6:50 pm

Thanks a lot for reply Moini!

The script ps2dxf.sh is interesting. However I'm not sure if Inkscape use it - it is a command wrapped around software pstoedit which was not installed on my system, but maybe it is shipped directly with Inkscape?

So I installed the pstoedit and it seems to be useful in the conversion with dxf as a target. Yet I have not managed to get results as precise as in the Inkscape GUI "save as dxf". I am struggling with final scale of drawing and lines width. I believe the scale is not such a problem and I could solve it with some easy calculations soon. Main trouble are lines/polylines, after conversion to dxf they have non zero width, that is wrong and have to be corrected to zero manually in CAD programs.

If Inkscape use the pstoedit for dxf conversion, it would be useful to know how Inkscape deals with the scale and foremost with the line width.

have a nice weekend guys

Moini
Posts: 3381
Joined: Mon Oct 05, 2015 10:44 am

Re: How to convert svg > dxf from CLI?

Postby Moini » Mon Jul 17, 2017 4:45 am

Inkscape (at least my Inkscape 0.92.1) has two options to save as dxf, one internal and one via that script, as far as I understand.
The internal one (option in 'Save as...' dialog that is with a '14') can't be used for automating, because it requires a GUI, while the script (for dxf verison 12) is available outside of Inkscape, too.

pstoedit is an optional dependency. If it is not installed on your computer, the extensions that use it will just not be available to you. (Latex extension requires it, too, for example).

Would these explain the issues that you found?
Something doesn't work? - Keeping an eye on the status bar can save you a lot of time!

Inkscape FAQ - Learning Resources - Website with tutorials (German and English)

Draftsman
Posts: 3
Joined: Thu Jul 13, 2017 2:14 am

Re: How to convert svg > dxf from CLI?

Postby Draftsman » Mon Jul 17, 2017 7:23 am

Would these explain the issues that you found?


Yes, thank You for clarifying.


Return to “Programming”