Importing

AutoCAD Map 3D .NET API

 
Importing
 
 
 

The import procedure brings in objects from external files and creates new drawing objects. Some external files have a single layer, while others have more than one.

To start an import process, get the Importer object for the application and initialize it with the import format name and the location of the file or files to import. For example::

myImporter.Init("SHP", fileName)

This sets up the available layers for the import. Iterate through the layers. For each layer, determine if objects from the layer will be imported. Set InputLayer.ImportFromInputLayerOn.

Any attribute data attached to objects in the layers can be brought into the drawing as object data. Each attribute in the source file corresponds to a column in the input layer. These columns can be mapped to fields in object data tables.

To map input columns, set the object data table name using InputLayer.SetDataMapping(). Then iterate through each column, setting the mapping for the column using Column.SetColumnDataMapping().

Different import drivers will have different options. The default options are stored in MapImport.ini. To modify the options, get the options using Importer.DriverOptions(). This returns a name-value collection. Modify the options in the collection and call Importer.SetDriverOptions().

Some drivers also have an options dialog. For those drivers, call Importer.InvokeDriverOptionsDialog() to have the user set the options.

When all the mappings and driver options have been set up properly, call Importer.Import(). This returns an ImportResults object, which contains details of the import.

Import Events

The RecordReadyForImport event handler can be used to control which records are imported. The handler is fired for every record, before the import has been completed. To stop the import for a record, set RecordReadyForImportEventArgs.ContinueImport to false.