Tuesday, December 30, 2008

Kellbot! · SDXF - Python Library for DXF

Kellbot! · SDXF - Python Library for DXF

Stani’s DXF library for python is an excellent tool for writing lines, circles, and polygons in DXF format. DXF (Document Exchange Format) is an ASCII file format published by AutoCad which can be read by a variety of programs, including Blender, Maya, CorelDraw, and a host of others.

I’ll attempt to document the library here as I figure it out, and also release updates to it as I slowly add more element types. I’m learning python and the DXF format as I go along so I can’t guarantee that any of this is correct.

Download SDXF 1.1.1

Changes in 1.1.1

  • Added support for LWPOLYLINE, so you can now make a continuous polyline instead of several separate lines

Example Code

This will draw a line from (0,0) to (1,1) and “Hello World” at (3,0)

import sdxf


#set the color of the text layer to green

#add drawing elements
d.append(sdxf.Text('Hello World!',point=(3,0),layer="textlayer"))
d.append(sdxf.Line(points=[(0,0),(1,1)], layer="drawinglayer"))