dxf Module
dxf.py - a DXF export library for python
Sample code:
import dxf
d = dxf.DXF(‘test.dxf’)
d.add_layer(‘ABC’, color=5)
d.add_entity(dxf.Line((1.5,5), (56,-89)), ‘ABC’)
d.save_to_file()
-
class gtrace.draw.dxf.Arc(center, radius, startangle, stopangle, thickness=0)[source]
Bases: gtrace.draw.dxf.Entity
An arc entity
-
draw(layername)[source]
-
report_min_max()[source]
Return the coordinates of the lower left and the upper right corners
of the drawing.
Return value: ((xmin, ymin), (xmax, ymax))
-
class gtrace.draw.dxf.Circle(center, radius, thickness=0)[source]
Bases: gtrace.draw.dxf.Entity
A circle entity
-
draw(layername)[source]
-
report_min_max()[source]
Return the coordinates of the lower left and the upper right corners
of the drawing.
Return value: ((xmin, ymin), (xmax, ymax))
-
class gtrace.draw.dxf.DXF(filename='drawing.dxf')[source]
Bases: object
A DXF file class.
-
add_entity(entity, layername)[source]
-
add_layer(name, color=1, ltype='Continuous')[source]
-
save_to_file()[source]
Save the DXF file
-
class gtrace.draw.dxf.Entity[source]
Bases: object
A graphic entity
-
draw()[source]
-
report_min_max()[source]
Return the coordinates of the lower left and the upper right corners
of the drawing.
Return value: ((xmin, ymin), (xmax, ymax))
-
set_handle(handle)[source]
-
class gtrace.draw.dxf.Layer(name, handle, color=1, ltype='Continuous')[source]
Bases: object
Layer class
-
add_entity(entity)[source]
-
class gtrace.draw.dxf.Line(start, stop, thickness=0)[source]
Bases: gtrace.draw.dxf.Entity
A line entity
-
draw(layername)[source]
-
report_min_max()[source]
Return the coordinates of the lower left and the upper right corners
of the drawing.
Return value: ((xmin, ymin), (xmax, ymax))
-
class gtrace.draw.dxf.LwPolyLine(x, y, thickness=0)[source]
Bases: gtrace.draw.dxf.Entity
A light weight poly-line
-
draw(layername)[source]
-
report_min_max()[source]
Return the coordinates of the lower left and the upper right corners
of the drawing.
Return value: ((xmin, ymin), (xmax, ymax))
-
exception gtrace.draw.dxf.NumberOfElementError[source]
Bases: exceptions.BaseException
-
class gtrace.draw.dxf.Rectangle(point, width, height, thickness=0)[source]
Bases: gtrace.draw.dxf.Entity
A rectangle
-
draw(layername)[source]
-
report_min_max()[source]
Return the coordinates of the lower left and the upper right corners
of the drawing.
Return value: ((xmin, ymin), (xmax, ymax))
-
class gtrace.draw.dxf.Text(text, point, height=1.0, rotation=0.0)[source]
Bases: gtrace.draw.dxf.Entity
Text
-
draw(layername)[source]
-
report_min_max()[source]
Return the coordinates of the lower left and the upper right corners
of the drawing.
Return value: ((xmin, ymin), (xmax, ymax))
-
gtrace.draw.dxf.color_encode(color)[source]
Given a set of RGB values for a color, find the closest matching
one from the pre-defined colors in the DXF specification.
Then return its color code (an integer in 1 to 255).
= Input =
color: A tuple of three numbers in the range of 0-255, i.e. (R,G,B)
= Return =
best_color_num: integer
-
gtrace.draw.dxf.test_func()[source]