Table of Contents

Method Open

Namespace
OpenCAD2D
Assembly
OpenCAD2D.Core.dll

Open(string)

Opens a DWG or DXF file: a DWG of AutoCAD 2000 to 2018 read by DwgReader, as Open(string) reads it, so that Save() writes it back as a DWG of AutoCAD 2018. A DXF whose header leaves out MEASUREMENT, the dimension variables, DIMSTYLE or CELTYPE reads them as AutoCAD does (MEASUREMENT 0, the dimension style Standard with DIMASZ 0.18, CELTYPE Continuous), and writes them into its header; a drawing made by From(DxfDatabase, string) keeps the library's own.

public static CadDocument Open(string path)

Parameters

path string

The path of the file.

Returns

CadDocument

The document.

Exceptions

ArgumentNullException

Thrown when the path is null.

NotSupportedException

Thrown when the file is a DWG of a version that is not read; the message names it.

Open(string, IProgress<double>)

Opens a DWG or DXF file as Open(string) does, telling how far the reading has got as Open(string, IProgress<double>) tells it: a share from 0 to 1, never going back, 1 once read. A CadProgressMeter is such a progress.

public static CadDocument Open(string path, IProgress<double> progress)

Parameters

path string

The path of the file.

progress IProgress<double>

What is told how far it has got, on the thread that opens; null for nothing.

Returns

CadDocument

The document.

Exceptions

ArgumentNullException

Thrown when the path is null.

NotSupportedException

Thrown when the file is a DWG of a version that is not read; the message names it.

Open(string, IProgress<double>, CancellationToken)

Opens a DWG or DXF file as Open(string, IProgress<double>) does, giving it up when a token says so: the window opens a drawing on a worker thread that Esc and Stop stop. A DXF is looked at every 4 096 records as its text is walked, its handles scanned and its entities of model space listed (the listing the first display would otherwise make, 0.3 s at 1 000 000 entities), so that a file of that size, 77 MB, is given up within a few milliseconds of the stop and not at the end of its reading, which took 0.5 s; a DWG is looked at before each page of it is unpacked, before each object is read and before each entity and object is written as DXF, and then every 4 096 records as that DXF is walked, so that one of 300 000 entities, whose reading takes 1.6 s, is given up within a few milliseconds as well.

public static CadDocument Open(string path, IProgress<double> progress, CancellationToken cancellationToken)

Parameters

path string

The path of the file.

progress IProgress<double>

What is told how far the reading has got, on the thread that opens; null for nothing.

cancellationToken CancellationToken

What stops the opening.

Returns

CadDocument

The document.

Exceptions

ArgumentNullException

Thrown when the path is null.

NotSupportedException

Thrown when the file is a DWG of a version that is not read; the message names it.

OperationCanceledException

Thrown when stopped before the file is read.

Open(Stream, string)

Opens a DXF from a stream, reading the header values it leaves out as Open(string) does.

public static CadDocument Open(Stream stream, string name = null)

Parameters

stream Stream

The stream of the bytes of the file.

name string

A name to show for it; null for none.

Returns

CadDocument

The document.

Exceptions

ArgumentNullException

Thrown when the stream is null.