For a project I need to automate the conversion of plenty .svg
-files to .dxf
-files for further processing.
Situation: One directory with plenty .svg
-files which should be converted to .dxf
(no matter if the .dxf
files are in the same diretory or in a subfolder, dxf name should be svg name)
I can do that with Inkscape GUI which also works for importing the .dxf
files in CAD programs, but as mentioned I need to automate that. (I've only written in Python so far).
My thought: I open the files in Inkscape via command line. Exporting in png
-format would be possible via command with following code:
from subprocess import call
import os
svg_dir = "C:\\temp\\layers\\"
files = [svg_dir + i for i in os.listdir(svg_dir) if ".svg" in i]
dir = r"C:\Program Files\Inkscape"
for i in files:
cmdline = "Inkscape -z -f "+ i +" -e "+ i + ".png"
rc = call("start cmd /K " + cmdline, cwd=dir, shell=True)
But I do not really unterstand Inkscape extensions. I only know that I need dxf_outlines.py/.inx
in the extension directory. I always need the same export options so could I just rewrite the Python code for that and run it via command in Inkscape?
Or would there be any solution without any extra software like Inkscape in Python? As far as I've seen there isn't.