Table of Contents

Class Import

Namespace
CADability.DXF
Assembly
CADability.dll

Imports a DXF file, converts it to a project

public class Import
Inheritance
Import
Inherited Members

Constructors

Import(string)

Reads the DXF file fileName with ACadSharp. The file is read into memory first; when its OBJECTS section, which holds no geometry, is malformed, the file is read again without that section. Nothing is converted yet: get Project to convert the drawing. Reading errors propagate as the exceptions of ACadSharp. A DWG file is recognized by its content and read with the DWG reader, whatever the extension of the file name.

public Import(string fileName)

Parameters

fileName string

path of the DXF or DWG file

Import(string, IDxfProgress)

Reads the DXF or DWG file fileName like Import(string) and reports the progress of reading the file here and of converting it later in Project to progress. Reading takes the first 60 percent, converting the model space and the paper space 20 percent each. SetCompleted() is called when the conversion is done or when reading or converting fails.

public Import(string fileName, IDxfProgress progress)

Parameters

fileName string

path of the DXF or DWG file

progress IDxfProgress

receives the progress, may be null

Properties

Project

Converts the drawing into a new Project and returns it. The model space becomes the first model of the project; a non-empty paper space is added as a second model named "*Paper_Space" (and shown instead when the model space is empty). Layers and the other table entries become attributes of the project. Each access converts the drawing again, so keep the result. Returns null when no document was read. Throws a DxfImportLimitException when the blocks of the drawing expand to more objects than the setting "DxfDwg.MaxImportObjects" allows.

public Project Project { get; }

Property Value

Project

Methods

CanImportVersion(string)

Tells whether ReadFromFile(string, string) can read this DXF or DWG file, judged by the drawing version stored in the file itself. Which of the two formats it is comes from the content, not from the extension. Only the head of the file is looked at, so this is cheap enough to call before every import.

public static bool CanImportVersion(string fileName)

Parameters

fileName string

Path of the DXF or DWG file to test

Returns

bool

true if the version is one that can be read

Exceptions

IOException

The file cannot be opened at all, which is not a version problem and therefore not reported as an unsupported version.

CanImportVersion(string, out string)

Same as CanImportVersion(string), but also reports the version found in the file so that a caller can name it in an error message.

public static bool CanImportVersion(string fileName, out string versionName)

Parameters

fileName string

Path of the DXF or DWG file to test

versionName string

Receives the drawing version found in the file, e.g. "AC1015" for AutoCAD 2000, or an empty string when the file carries no version

Returns

bool

true if the version is one that can be read

Exceptions

IOException

The file cannot be opened at all, which is not a version problem and therefore not reported as an unsupported version.