Function Reference: 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. 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; 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; a file declaring none is read as millimetres. The reader takes ASCII DXF from R12 (AC1009) to R2018 (AC1032); text before R2007 is 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