Shapes Management¶
Prelude:
from dxfwrite import DXFEngine
dwg = DXFEngine.drawing('newdrawing.dxf')
How to create new Shapes?¶
Shapes like LINE or CIRCLE
will be created by the DXFEngine
object. A new created
shape is not automatically added to the drawing, this is done by the
Drawing.add()
method of the Drawing
object.
line = DXFEngine.line( (0, 0), (1, 1) )
dwg.add(line)
See also
DXFEngine
for available entities
How to set/get DXF attributes?¶
This is common to all basic DXF entities (not valid for composite entities):
# as keyword arguments
line = DXFEngine.line((0,0), (1,1), layer='TESTLAYER', linetype='DASHED', color=1)
# or:
line['layer'] = 'TESTLAYER'
line['linetype'] = 'DASHED'
line['color'] = 1
Where should the shapes be placed?¶
You can add the shapes to the drawing, which means adding the shape to the model space:
line = DXFEngine.line((0, 0), (1, 1)) dwg.add(line)
You can add the shape explicit to the model space of the drawing:
dwg.modelspace.add(line)
You can add the shape to the paper space (layout) of the drawing:
dwg.paperspace.add(line)
Note
The DXF R12 Standard supports only one paper space (layout).
You can add the shape to a BLOCK definition entity:
blockdef = DXFEngine.block('testblk') blockdef.add(line)