A Python library to create DXF R12 drawings.
Project description
dxfwrite
Abstract
A Python library to create DXF R12 drawings.
a simple example:
from dxfwrite import DXFEngine as dxf drawing = dxf.drawing('test.dxf') drawing.add(dxf.line((0, 0), (10, 0), color=7)) drawing.add_layer('TEXTLAYER', color=2) drawing.add(dxf.text('Test', insert=(0, 0.2), layer='TEXTLAYER')) drawing.save()
supported DXF R12 entities
ARC
ATTDEF
ATTRIB
BLOCK
CIRCLE
3DFACE
INSERT
LINE
POINT
POLYLINE (special Polyface and Polymesh objects are available)
SHAPE (not tested)
SOLID
TRACE
TEXT
VERTEX (only for internal use, see Polyline, Polyface and Polymesh objects)
VIEWPORT
not supported DXF R12 entities
DIMENSION
emulated entities from DXF R13 and later
MTEXT (R13) … emulated as composite entity MText
ELLIPSE (R13) … approximated by Ellipse
SPLINE (R13) … approximated by Spline
LWPOLYLINE (R13) … use POLYLINE
TABLE (R2005) … emulated as composite entity Table
composite entities
MText – multi-line text
LinearDimension
AngularDimension
ArcDimension
RadialDimension
Table – text and blockrefs containing table like a HTML-table
Ellipse – approximated as POLYLINE
Spline – cubic spline curve through breakpoints without additional control points, approximated as POLYLINE
Bezier – cubic bezier curve through breakpoints with additional control points, approximated as POLYLINE
Clothoid – Euler spiral, approximated as POLYLINE
read/write AutoCAD ctb-files
The module acadctb provides the ability to read and write AutoCAD ctb-files. With ctb-files you can assign a new color or lineweight to a dxf-color-index for plotting or printing, but this has to be supported by the used application.
a simple example:
from dxfwrite import acadctb ctb = acadctb.load('test.ctb') style1 = ctb.get_style(1) # dxf color index (1 .. 255) style1.set_color(23, 177, 68) # set rgb values (0..255) style1.set_lineweight(0.7) ctb.save('new.ctb')
Installation
with pip:
pip install dxfwrite
or from source:
python setup.py install
Documentation
http://dxfwrite.readthedocs.org http://packages.python.org/dxfwrite/
The source code repository of dxfwrite can be found at bitbucket.org:
http://bitbucket.org/mozman/dxfwrite
Feedback is greatly appreciated.
mozman <mozman@gmx.at>
News
Version 1.2.0 - August 2012
License changed to MIT License
tested on Win7 with: CPython2.7, CPython3.2, CPython 3.3 beta, pypy-1.9
Version 1.1.0 - 29 December 2011
rewrite of DXF-String building process
refactored MText class
changed Viewport table entry to VPort and DXFEngine.viewport to DXFEngine.vport. This was necessary to implement the VIEWPORT (Entity)
added VIEWPORT (Entity) to create viewports in paper space
view docs also on http://dxfwrite.readthedocs.org
added some docs
changed clothoid mirror parameters
added methods to class Layer: on(), off(), freeze(), thaw(), lock(), unlock()
tested on Win7 32 Bit with CPython-2.7, CPython-3.2 and pypy-1.7, IronPython 2.7 failed tests - unicode issues
tested on Ubuntu 11.10 64 Bit with CPython-2.7, CPython-3.2 and pypy-1.7
Version 1.0.2 - 08 December 2011
raw unicode encoding by Toni Ruža - use any unicode character for text and table-entries.
Version 1.0.1 - 26 March 2011
added easy usage of modelspace/paperspace, see examples/paperspace.py
BUGFIX: removed dict-comprehension in module htmlcolors.py for backward-compatibility to Python 2.5 and 2.6, works with pypy 1.4.1
Version 1.0.0 - 11 March 2011
changed: set DXF Header variables now looks like dwg.header[‘$VAR’] = value, see http://packages.python.org/dxfwrite/headervars.html
splitted makedxfexamples.py into several files and moved them into the subdir ‘examples’
curves.Ellpise: radiusx -> rx; radiusy -> ry
moved documentation to: http://packages.python.org/dxfwrite, and using Sphinx (http://sphinx.pocoo.org)
tested with Python 3.2 - OK
further compatibility-tests only for CPython 2.7 & CPython 3.2+
added Drawing.add_xref(filename), for usage see examples/xref.py
adding relative attributes by Insert.add() consider the xy-scaling
added Howtos section to documentation
Version 0.3.6 - 14 November 2010
moved dxfwrite.drawing.ENCODING to class Drawing
Python 3.1 support
Version 0.3.5 - 10 September 2010
new: package and tests run with Python 2.7
Version 0.3.4 - 29 August 2010
status: 5 - Production/Stable
new: package and tests run with Python 2.5 (tests need unittest2)
Version 0.3.3 - 27 April 2010
BUGFIX: makedxfexamples.py - attdef keyword error
Version 0.3.2 - 27 April 2010
BUGFIX: Drawing.__dxf__() - StringIO() does not support ‘with’ statement
Version 0.3.1 - 24 April 2010
new: insert2, insert block reference with automatic attrib filling
changed interface for DXFEngine.attrib()
Version 0.3.0b1 - 28 March 2010
new: subpackage algebra: circle, ray, clothoid, cspline, bezier (27.03.2010)
new: Spline, Bezier, Clothoid and Ellipse - curves (27.03.2010)
new: acadctb.py to read, write and create AutoCAD ctb-files (25.03.2010)
splitted buildups.py into mtext.py and rect.py
Version 0.2.0 - 21 March 2010
Alpha status - api may change
Version 0.1.0 - 14 March 2010
Pre-Alpha status
Initial release
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
File details
Details for the file dxfwrite-1.2.0.zip
.
File metadata
- Download URL: dxfwrite-1.2.0.zip
- Upload date:
- Size: 151.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb07c330673068cd784ba928b3b7e868dfa3ec2d72e2b6dd79693c94e52b6f84 |
|
MD5 | 3968d8ce155379d35b4d4666bb68c7e2 |
|
BLAKE2b-256 | e8aa087a76bcd4c1c4b2d413150accf2f35178a5e37ef89d57b5f8ab77e7c072 |
File details
Details for the file dxfwrite-1.2.0.tar.gz
.
File metadata
- Download URL: dxfwrite-1.2.0.tar.gz
- Upload date:
- Size: 101.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 647788d3d384d8ebf665a646a0d2e0f32fb4b4d51fdc8f458c44681785d6cd6a |
|
MD5 | 56bd40206e6dbf4a3be2f3b6936a2c4f |
|
BLAKE2b-256 | 75722226dbddea6e556857efbc59f51a8b0882b71bc830bdfdd37b536a89cab6 |