Wiki
Clone wikidxf2svg / Home
#DXF2SVG - basic python dxf to svg converter
Please read README file first to get know basic information and install dxf2svg package.
Dxf2svg is based on ezdxf and svgwrite packages - special thanks for the creator of those packages.
At the moment dxf2svg is alpha stage.
##What is the problem does it solve?
DXF format is one of most popular format for making drawing. There is many efficient tool to work with it (Autocad, Draftsight, Librecad etc.). The problem is that dxf format can not be included directly in text document if you want put dxf inside. To do it, dxf must be converted to some image format like BMP, JPG, SVG and then attached to text document. Converting process can be made by using export or print option in graphic application or even using printscreen, but it takes time and is not automatic. The problem is more complicated if you want get more than one image from one dxf file. DXF2SVG solve this problem.
##Use example
###Working with command line
Lets spouse you have dxf2svg installed and have same DXF file you have done. The example bird.dxf
file modelspace look like this.
open command-line interface, move to directory where the DXF file is and execute command
python -m dxf2svg bird.dxf
then bird.svg
file will be created in the same directory and it looks like this
bird.svg
It is possible to get more than one svg from one dxf file. What you need to do is define additional frames with names in modelspace - those are rectangle and text on svgframe
layer. Here is bird.dxf
modelspace with additional frames.
execute again the command
python -m dxf2svg bird.dxf
then files bird_all.svg
, bird_head.svg
, bird_feet.svg
, bird_winds.svg
wil be created, those files look like this
bird_all.svg
bird_head.svg
bird_feet.svg
bird_wings.svg
You can also define svg size by using sizes parameter then the command is
python -m dxf2svg bird.dxf 500
where the integer number is image pixel size of longer side of the image rectangle.
###Working with python code
To use dxf2svg features from python, first import needed function
from dxf2svg.pycore import save_svg_from_dxf, extract_all
and use them with parameters you need
save_svg_from_dxf(dxffilepath, svgfilepath=None, frame_name=None, size=300)
extract_all(dxffilepath, size=300)
Updated