draw.read
drafting: D = draw.read (FILE)
Read a drawing from an ASCII DXF file.
D = draw.read (FILE) returns the drawing in FILE
as a draw.Drawing named 'imported', which can then be
transformed, merged into a sheet, dimensioned further and written out
again. Each entity is appended on its own layer, line type and colour,
and the drawing is left on its defaults afterwards. The file’s layer
table comes with it into Layers: each layer’s colour, line type,
line weight, whether it is switched off or frozen, which both read as not
visible, and whether it is printed. An entity that takes its colour, line
type or line weight from its layer keeps doing so, so the drawing looks as
it did and a layer changed later changes everything on it.
Geometry returns as itself: lines, points, arcs, circles, ellipses, polylines
with their bulges, splines, text, and inserts of the blocks the file defines,
nested blocks included, each block moved so that its base point is its
origin, where an insert places it. A HATCH returns as a hatch over
the regions it fills, its pattern, angle and spacing kept; a pattern the
package does not define is drawn as 'ANSI31'. A path or a region the
package wrote, through draw.Drawing.write, returns as that path or
region. An MTEXT returns as one line of text, its formatting removed.
A DIMENSION returns as a dimension: its definition points name what
it measures, so a linear, aligned, angular, diameter, radius or ordinate
dimension is rebuilt as the method that would have made it, and it
measures the geometry again rather than repeating a number. The picture
of a dimension lives in a block nothing places, and that block is dropped,
as are the layout blocks a file defines; a block that is placed is kept.
A drawing lies in the plane z = 0. An entity whose normal points down the z axis is mirrored into the plane facing up, as 2-D CAD programs treat it; heights are dropped. An entity on any other plane, a mesh, a solid, an entity in paper space, an insert of a block the file does not define and an entity type the package does not draw are skipped, as is the width of a polyline, which the package does not draw. So is a mirrored insert, or one scaled unequally in x and y, since a drawing places a block turned and scaled alike in both; rows and columns of an insert are placed one insert each. Whatever is skipped is reported in one warning, counted by entity type.
Coordinates are converted to millimetres from the units the file declares
in $INSUNITS, any of those DXF defines; a file declaring none is
read as millimetres, and so is one declaring a code DXF does not define,
with a warning. The reader takes ASCII DXF from R12 (AC1009) to
R2018 (AC1032); text and names before R2007 are decoded from the
code page the header names, and from R2007 on as UTF-8. A binary DXF is
an error.
See also: draw.Drawing, draw.Drawing.write, geom.read
Source Code: draw.read