Table of Contents

Class DwgReader

Namespace
GeometryHelper.Dwg
Assembly
GeometryHelper.dll

Reads a DWG file as the drawing its DXF would give: the same DxfDocument that DxfReader makes and the same DxfDatabase that Open(string) opens, so everything that works on a DXF works on a DWG.

public static class DwgReader
Inheritance
DwgReader
Inherited Members

Remarks

DWG files of AC1015 (AutoCAD 2000), AC1018 (AutoCAD 2004), AC1021 (AutoCAD 2007), AC1024 (AutoCAD 2010), AC1027 (AutoCAD 2013) and AC1032 (AutoCAD 2018 and later) are read. A file of another version, R14 and older among them, or one protected by a password, is refused with a NotSupportedException that names the version.

The file is turned, in memory, into the DXF that says the same, record for record with the handles of the file: the header variables, the classes, the nine tables, the blocks, the entities and the objects. Read are LINE, POINT, CIRCLE, ARC, ELLIPSE, SPLINE, RAY, XLINE, LWPOLYLINE, the 2D and 3D POLYLINE with their vertices, the polygon and polyface mesh, TEXT, MTEXT, ATTDEF, INSERT, alone or as an array, with its ATTRIBs, SOLID, TRACE, 3DFACE, SHAPE, DIMENSION, VIEWPORT, HATCH, LEADER, MULTILEADER, TOLERANCE, MLINE, OLE2FRAME, IMAGE, WIPEOUT and ACAD_TABLE, and of the objects DICTIONARY, XRECORD, LAYOUT, GROUP, MLINESTYLE, MLEADERSTYLE, TABLESTYLE, MATERIAL, VISUALSTYLE, the detail and section view styles, the FIELD and FIELDLIST of fields, the SORTENTSTABLE of the draw order, the CELLSTYLEMAP of a table style of AutoCAD 2000 to 2007, the data of a dynamic block of a linear parameter and a stretch action, the DATALINK of a table linked to data and the small ones a new drawing holds (see the guide for the full list); the ACIS data of the solids comes as SAT text to AutoCAD 2010, turned from the SAB AutoCAD keeps from AutoCAD 2004 into the SAT AutoCAD writes of it, and from AutoCAD 2013 from the data store of the file as the section ACDSDATA; each with its layer, linetype, colour, lineweight, owner, reactors, extension dictionary and extended data. A SHAPE is named from the file of shapes of its style where SupportFolders holds it, and else gives its number (group 70), as AutoCAD writes a shape whose file it does not find. An OLE2FRAME comes as the DXF of AutoCAD writes it, its binary in the groups 310, so that it is read as a DxfOle2Frame. The preview image of the file, where it holds a picture, comes as the section THUMBNAILIMAGE of the DXF, last. The types not read yet (those AutoCAD 2021's own sample drawings hold are the other objects of dynamic blocks and of associative dimensions; and there are the proxies) are left out and counted by type in one Debug line of GeometryHelperLog.

The check sums of the file are checked. A wrong one in the file header, the header variables, the classes or the object map, or from AutoCAD 2004 in a page of the file (from AutoCAD 2007 to 2009 its CRCs of 64 bits), refuses the file with a FormatException, and so does a file cut short there; one object with a wrong check sum, or that cannot be decoded, is left out, the others are read, and a Warn line counts them.

DxfDocument drawing = DwgReader.Read("plan.dwg", new DxfReadOptions { PlanAs2D = true });
DxfDatabase database = DwgReader.Open("plan.dwg");

Methods

Open(Stream)

Opens a DWG file from a stream, from where the stream stands to its end, as a drawing database.

Open(string)

Opens a DWG file from a path as a drawing database, as Open(string) opens its DXF.

Open(string, DxfReadOptions)

Opens a DWG file from a path as a drawing database, its SHAPEs named from the files of shapes in the folders of SupportFolders.

Read(Stream, DxfReadOptions)

Reads a DWG file from a stream, from where the stream stands to its end.

Read(string, DxfReadOptions)

Reads a DWG file from a path into the library's shapes, as Read(string, DxfReadOptions) reads its DXF.