draw.Drawing

Methods

Method Reference: draw.Drawing.write

draw.Drawing: write (D, FILE)

draw.Drawing: write (D, FILE, Name, Value, …)

Write a drawing to a DXF file.

write (D, FILE) writes the drawing D to FILE, which must end in .dxf, as an AutoCAD R2000 (AC1015) ASCII DXF drawing in millimetres. The layer table is written whole: every layer of Layers with its colour, line type and line weight, switched off where it is not visible and marked not to print where it is not printed. Every entity is written on its layer, by layer where it takes its properties from it, so a CAD program that changes a layer changes everything on it. Line types are declared with the dash pattern of every line type the package defines. A line weight is written as the nearest of the weights DXF allows; R12 holds none.

Each entity is written as itself: a line, point, arc, circle, ellipse, text, spline, insert and polyline, its bulges kept, as the DXF entity of the same name, a polyline as an LWPOLYLINE; a hatch as a HATCH over its region, the holes left clear, with its pattern, angle and spacing; a path as its pieces and a region as its loops, each bound by a group that names the class, so draw.read gives them back as a path and a region. A dimension is a DIMENSION whose picture is an anonymous block, so a CAD program measures it again; the picture is on layer '0' and by block, as CAD programs draw it, so the dimension’s own layer and properties govern it. A centre mark and a leader are written as the lines and text they are drawn with. The blocks the drawing defines are written once each and placed by INSERT.

Name/Value pairs:

'Version'
'R2000', the default, or 'R12' (AC1009) for a program that reads nothing later. R12 holds only lines and arcs, so a drawing holding an ellipse, a spline, a path, a region or a hatch is an error there, naming what R12 cannot hold.
'Dimensions'
'associative', the default, or 'explode' to write each dimension as the lines and text it is drawn with, for a program that cannot read a DIMENSION.
'Blocks'
'reference', the default, or 'expand' to copy each block’s contents in place of every insert, for a program that ignores INSERT.
'DimScale'
Multiplies the dimension ornament, which is a model dimension: a drawing meant for 1:50 wants 50 here. 1 by default.
'LTScale'
The drawing’s line-type scale, 1 by default, written in the header so the dashes look the same wherever the file is opened.

Text is written with every character outside ASCII escaped as \U+XXXX, so the file reads the same whatever the reader’s code page.

See also: draw.read, draw.Drawing.print, draw.Drawing.tikz, geom.write

Source Code: draw.Drawing