Class DxfReader
- Namespace
- GeometryHelper.Dxf
- Assembly
- GeometryHelper.dll
Reads a DXF file into the library's shapes: what DxfWriter writes, back to the bit where the file holds the number, and what AutoCAD and the other CAD programs write of the same kinds, from R12 to R2018.
public static class DxfReader
- Inheritance
-
DxfReader
- Inherited Members
Remarks
The entities of the drawing are read in the order of the file, each with its layer, its colour and its handle: a POINT, LINE, RAY and XLINE as the point, segment, ray and line without ends they are; a LWPOLYLINE and a POLYLINE of the plane as a chain or a polygon, with arcs where an edge has a bulge; a 3D POLYLINE as a chain or a polygon in space; a polyface or polygon mesh as a body of its faces; a CIRCLE, ARC and whole ELLIPSE as themselves; a part of an ELLIPSE and a SPLINE as a spline, exactly; a 3DFACE as a triangle or a face, a SOLID or TRACE as a polygon; a TEXT and an MTEXT as a DxfText; a LEADER as its curve, the chain of its vertices or, splined, the spline fitted through them, as Explode() fits one; and a MULTILEADER as the lines of its leaders, as DxfMLeader sets them out. Entities of space are read as shapes of space unless PlanAs2D asks for those lying on the floor as shapes of the plane. An INSERT is read as the entities of its block, each placed where the INSERT puts it, with the look it takes from the INSERT and the names of the blocks it was placed through (ExpandBlocks); the blocks themselves are in Blocks, and the layers of the layer table in LayerTable. DIMENSION, HATCH, ATTRIB and the other types are left out and counted in Skipped, and so is an entity with no shape to it, a LINE of no length among them; the entities of paper space are not read, and a warning counts them.
Every number is read as the file prints it, the double nearest it on either runtime, so a file the library wrote gives back every coordinate, radius, bulge, knot and weight it holds to the bit: a polyline of the plane read with PlanAs2D is the polyline written. What the file holds in another form comes back to the last place or two: the angles of an ARC are degrees in the file, an ELLIPSE keeps the end of its major axis and the ratio of its radii, and a circle, arc or polyline in a tilted plane keeps its coordinates in the plane's own system.
A file that is not a DXF, or is cut short, is refused with a FormatException that names the line; a binary DXF is refused the same way. One entity that cannot be read never stops the others.
DxfDocument drawing = DxfReader.Read("plan.dxf", new DxfReadOptions { PlanAs2D = true });
foreach (GeoPolygonArc2 outline in drawing.OfType<GeoPolygonArc2>()) { ... }
Methods
- Parse(string, DxfReadOptions)
Reads a DXF file from its text.
- Read(Stream, DxfReadOptions)
Reads a DXF file from a stream, from where the stream stands to its end.
- Read(string, DxfReadOptions)
Reads a DXF file from a path.