Skip to content

Instantly share code, notes, and snippets.

@vmario89
Last active November 2, 2021 07:47
Show Gist options
  • Save vmario89/4b173c0ad4a03d3773ef8dd938c54621 to your computer and use it in GitHub Desktop.
Save vmario89/4b173c0ad4a03d3773ef8dd938c54621 to your computer and use it in GitHub Desktop.
Convert DXF to SVG using ezdxf
#!/usr/bin/env python3
import matplotlib.pyplot as plt
import ezdxf
from ezdxf.addons.drawing import RenderContext, Frontend
from ezdxf.addons.drawing.matplotlib_backend import MatplotlibBackend
doc = ezdxf.readfile(YOURFILE)
fig = plt.figure()
out = MatplotlibBackend(fig.add_axes([0, 0, 1, 1]))
Frontend(RenderContext(doc), out).draw_layout(doc.modelspace(), finalize=True)
#fig.savefig(os.path.join(temp_output_dir, outputfilebase + ".png"), dpi=300)
fig.savefig(os.path.join(temp_output_dir, outputfilebase + ".svg"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment