Method Recover
- Namespace
- GeometryHelper.Dxf
- Assembly
- GeometryHelper.dll
Recover(string, out DxfRepairReport)
Opens a damaged DXF file from a path, as AutoCAD's RECOVER opens one: what can be read of it, repaired, with a report of what was found and done. A sound file is opened as Open(string) opens it, every byte kept, with an empty report.
public static DxfDatabase Recover(string path, out DxfRepairReport report)
Parameters
pathstringThe path of the file.
reportDxfRepairReportWhat was found wrong and what was done, in the order it was found.
Returns
- DxfDatabase
The drawing; never null.
Remarks
The file is read as pairs of lines whatever is wrong with them, then put right where it can be, in the order of
DxfRepairKind: a line that is not a group code left out; a file cut short closed with its ENDSEC and
EOF; the sections closed and put in order, ENTITIES added where there is none; the text of a file of R2007 or later
that is not UTF-8 read in its code page; a number that is no number given the number it begins with, or nought; an
entity with a number that is not finite left out; the counts of a LWPOLYLINE and a HATCH set to their parts; a handle
two records have, or one missing, given a new one; an owner that names nothing pointed at the block, table or
polyline the record stands in; an ENDBLK, a SEQEND and $HANDSEED written where missing. The file so written
is then opened, and audited as Audit(bool) audits it, fixing: layers, linetypes, text styles and dimension
styles the entities name and the tables lack are added; a broken entry of a dictionary is taken out. An
INSERT of a block not defined, an entity of a type unknown, a missing TABLES, BLOCKS or OBJECTS section are reported
and left as they are.
A drawing of R2018 of 12 INSERTs, a hatch, two polylines, a text, a dimension and three lines, cut off after the code of the first point of its last line, opens with every entity but that line whole, the line read with no point, and a report of 3 errors found, 2 fixed: the code with no value left out, the file closed with its ENDSEC and EOF, and its OBJECTS section, lost with the cut, reported. It saves as a file Open(Stream) opens. Where what was repaired still cannot be read, its entities alone are kept, and failing that the drawing is empty; both are said in the report (Unreadable).
Exceptions
- ArgumentNullException
Thrown when the path is null.
- IOException
Thrown when the file cannot be read.
- FormatException
Thrown for a binary DXF, which is not damaged but not read: save it as an ASCII DXF.
Recover(Stream, out DxfRepairReport)
Opens a damaged DXF file from a stream, from where the stream stands to its end, as Recover(string, out DxfRepairReport) opens one from a path.
public static DxfDatabase Recover(Stream stream, out DxfRepairReport report)
Parameters
streamStreamThe stream; it is read to its end and left open.
reportDxfRepairReportWhat was found wrong and what was done, in the order it was found.
Returns
- DxfDatabase
The drawing; never null.
Exceptions
- ArgumentNullException
Thrown when the stream is null.
- FormatException
Thrown for a binary DXF.