By importing a map, you can combine data from other mapping or GIS programs by importing the data into AutoCAD Map 3D. You can import the map objects themselves, and the data and display options associated with them. In addition, you can specify an import area to determine which area of the map will be imported, assign incoming objects to existing feature classes, and automatically perform a coordinate conversion on the objects as they are imported.
By exporting a map, you can export data to an external file format. You can export the map objects themselves, and the data associated with them, and specify that AutoCAD Map 3D performs a coordinate conversion on the objects automatically as they are exported.
Use profiles to save your import and export settings in a profile to automate the process of importing and exporting files. You can save and load import profile files (.ipf) or export profile files (.epf).
The following file formats are supported for both import and export, unless otherwise indicated:
- ArcView ShapeFile (also called ESRI ShapeFile or ESRI Shape)
- ArcInfo Coverages and E00
- GML (Geography Markup Language) version 2
- GML (Geography Markup Language) version 2, Ordinance Survey of Great Britain MasterMap (import only)
- MapInfo MIF/MID
- MapInfo TAB
- MicroStation DGN versions 7 and 8
- SDTS (Spatial Data Transfer Standard) (import only)
- VML (Vector Markup Language) (export only)
- VPF (Vector Product Format) (import only)
See
also
To import an file to an AutoCAD Map 3D drawing, perform the following steps, as shown in the sample code that follows:
- Retrieve the Autodesk Map importer object, an AcMapIEImporter singleton instance, by calling the global function AcMapImporter().
- Initialize the importer
with Init().
(You must call Init() before you call any other AcMapIEImporter functions.)
Init() requires an AcMapIEFormat name that specifies the format of the incoming file.
- Optionally,
add reactors to the importer. Set the import options. Use LoadIPF() to load previously saved import settings from a profile (.ipf) file. (You can save the current import options in a profile file with SaveIPF().)
- Call Import() to
perform the import.
Import results are stored in an AcMapIE::CImportResults struct.
For
import-export source-code samples, see
AcMapIE::ErrCode errCode;
// Retrieve the AutoCAD Map 3D importer object.
AcMapIEImporter* pImporter = AcMapImporter();
// Initialize the importer.
char* pszFormat = "MIF"; // Name of an AcMapIEFormat.
char* pszImpFileName = "C:\\temp\\my_import_file.mif";
errCode = pImporter->Init(pszFormat, pszImpFileName);
if (errCode != AcMapIE::kErr_OK)
{
// Handle the error.
}
// Get an iterator over the layers in the imported file.
AcMapIEInputLayerIterator* pInputLayers;
errCode = pImporter->InputLayerIterator(pInputLayers);
if (errCode != AcMapIE::kErr_OK)
{
// Handle the error.
}
// Iterate over each layer.
for (pInputLayers->Rewind(); !pInputLayers->Done(); pInputLayers->Step())
{
AcMapIEInputLayer* pLayer = NULL;
if(pInputLayers->Get(pLayer) == false)
{
// Handle the error.
}
// Import attribute data from the import file to the
// new object-data table in the Autocad Map drawing.
// Insert code to set the table type and table name
// with AcMapIEInputLayer::SetDataMapping()
// and set the feature class name
// with AcMapIEInputLayer::SetFeatureClassName().
// Set column mappings.
AcMapIEColumnIterator* pColumns = pLayer->ColumnIterator();
if(pColumns)
{
for (pColumns->Rewind(); !pColumns->Done(); pColumns->Step())
{
// Insert code to set column data mappings
// with AcMapIEColumn::SetColumnDataMapping()
// and set column feature-class mappings
// with AcMapIEColumn::SetColumnClassMapping().
}
delete pColumns;
}
delete pLayer;
}
delete pInputLayers;
// Perform the import and get the results.
AcMapIE::CImportResults results;
bool bUseProgressDialog = false;
errCode = pImporter->Import(results, bUseProgressDialog);
if(errCode != AcMapIE::kErr_OK)
{
// Handle the error.
}
// Process or log the import results, if desired.
When
importing a drawing into AutoCAD Map 3D, you can set import options for
each incoming layer. AcMapIEImporter::InputLayerIterator() retrieves
an
- Data-mapping table type and name - DataMapping()/SetDataMapping(). See also AcMapIE::ImportDataMapping enum.
- Feature class - FeatureClassName()/SetFeatureClassName()
- Import-layer switch - ImportFromInputLayerOn()/SetImportFromInputLayerOn()
- Layer name - LayerName()/SetLayerName(). See also AcMapIE::LayerNameType enum.
- Point-import mode - PointToBlockMapping()/SetPointToBlockMapping(). See also AcMapIE::PointMappingType enum.
- Target coordinate system - TargetCoordSys()/SetTargetCoordSys(). See also OriginalCoordSys().
- Import-attributes switch - UseForBlockAttributes()/SetUseForBlockAttributes()
- Unique keys for imported objects - UseUniqueKeyField()/SetUseUniqueKeyField()
On
each layer, you can set individual mappings from each incoming column to
a target column in AutoCAD Map 3D. AcMapIEInputLayer::ColumnIterator() retrieves
an
- Data mapping - ColumnDataMapping()/SetColumnDataMapping().
- Feature-class mapping - ColumnClassMapping()/SetColumnClassMapping(). Feature-class mappings are not set by default for any column.
You also can use the following AcMapIEImporter functions to set and retrieve high-level import options:
- Audit classified properties - AuditClassifiedAfterImport()/SetAuditClassifiedAfterImport()
- Driver options - DriverOptions()/SetDriverOptions()/InvokeDriverOptionsDialog()
- Import polygons as closed polylines - ImportPolygonsAsClosedPolylines()/SetImportPolygonsAsClosedPolylines()
- Location-window filter - LocationWindowAndOptions()/SetLocationWindowAndOptions(). See also AcMapIE::LocationOption enum.
- Reactors - AddReactor()/RemoveReactor();
see
Using Reactors with Export and Import Events
For
import-export source-code samples, see
To export an AutoCAD Map 3D drawing, perform the following steps, as shown in the sample code that follows:
- Retrieve the Autodesk Map exporter object, an AcMapIEExporter singleton instance, by calling the global function AcMapExporter().
- Initialize the exporter
with Init().
(You must call Init() before you call any other AcMapIEExporter functions.)
Init() requires an AcMapIEFormat name that specifies the target file format. You can use FormatName() to retrieve the format name at any time after initialization.
- Optionally,
add reactors to the exporter. Set the export options. Use LoadEPF() to load previously saved export settings from a profile (.epf) file. (You can save the current export options in a profile file with SaveEPF().)
- Call Export() to
perform the export.
Export results are stored in an AcMapIE::CExportResults struct.
For
import-export source-code samples, see
AcMapIE::ErrCode errCode;
// Retrieve the AutoCAD Map 3D exporter object.
AcMapIEExporter* pExporter = AcMapExporter();
// Initialize the exporter.
char* pszFormat = "MIF"; // Name of an AcMapIEFormat.
char* pszExpFileName = "C:\\temp\\my_export_file.mif";
errCode = pExporter->Init(pszFormat, pszExpFileName);
if (errCode != AcMapIE::kErr_OK)
{
// Handle the error.
}
// Insert code to set filter, data mapping,
// and other <a href="#export_options">export options</a>.
// Perform the export and get the results.
AcMapIE::CExportResults results;
bool bUseProgressDialog = false;
errCode = pExporter->Export(results, bUseProgressDialog);
if (errCode != AcMapIE::kErr_OK)
{
// Handle the error.
}
// Process or log the export results, if desired.
Use export options to control which objects in the current drawing are exported by applying a layer filter, feature-class filter, and selection set. (CountObjects() counts the number and type of entities to export.) You also can set storage options, driver options, data mappings, and other options. Use the following AcMapIEExporter functions to set and retrieve export options:
- Discretization angle - DiscretizationAngle()/SetDiscretizationAngle()
- Driver options - DriverOptions()/SetDriverOptions()/InvokeDriverOptionsDialog()
- Export closed polylines as polygons - ClosedPolylinesAsPolygons()/SetClosedPolylinesAsPolygons()
- Feature classes to export - FeatureClassFilter()/SetFeatureClassFilter()
- Layers to export - LayerFilter()/SetLayerFilter()
- Mapping layers to DGN levels - LayerLevelMapping()/SetLayerLevelMapping()
- Polygon topology - ExportFromPolygonTopology()/SetExportFromPolygonTopology()
- Selection set - SelectionSet()/SetSelectionSet() and ExportAll()/SetExportAll()
- Source-column and output-column data mappings - ExportDataMappings()/SetExportDataMappings()
- Storage options - StorageOpts()/SetStorageOpts(). See also AcMapIE::StorageType enum and AcMapIE::GeometryType enum.
- Target coordinate system - TargetCoordSys()/SetTargetCoordSys()
- Unique keys for exported objects - UseUniqueKeyField()/SetUseUniqueKeyField()
- Reactors - AddReactor()/RemoveReactor();
see
Using Reactors with Export and Import Events
For
import-export source-code samples, see
Using Reactors with Export and Import Events
TheAcMapIEExportReactorandAcMapIEImportReactorreactor classes provide callback functions that notify an application immediately of export and import events. You can use these mechanisms to monitor or control export and import operations by adding reactor instances. Functions are invoked automatically depending on the stage of the operation, as described in the following tables:
Export reactor function | Invoked |
---|---|
RecordError() | If an error occurs during export |
RecordExported() | After an entity is exported |
RecordReadyForExport() | Before an entity is exported |
Import reactor function | Invoked |
---|---|
RecordError() | If an error occurs during import |
RecordImported() | After an entity is imported |
RecordReadyForImport() | Before an entity is imported |
You can add or remove export reactors with AcMapIEExporter::AddReactor() or AcMapIEExporter::RemoveReactor(), and add or remove import reactors with AcMapIEImporter::AddReactor()or AcMapIEImporter::RemoveReactor(). To use a reactor, perform the following steps, as shown in the sample code that follows:
- Derive a custom class from AcMapIEExportReactor or AcMapIEImportReactor.
- Implement events by overriding the virtual functions that you need.
- Create an instance of the custom reactor.
- Add the instance so that it becomes active.
- Write some export or import reactor code.
- Remove the reactor and delete it.
For
import-export source-code samples, see
// Derive a custom class from AcMapIEExportReactor.
class AcMapIEMyExportReactor : public AcMapIEExportReactor
{
// Override virtual functions for the desired export events.
} ;
// Create an instance of the custom reactor.
AcMapIEMyExportReactor* pMyReactor = new AcMapIEMyExportReactor;
// Add the custom reactor.
AcMapIEExporter().AddReactor(pMyReactor);
// Insert export reactor code here.
// Remove the reactor and delete it.
AcMapIEExporter().RemoveReactor(pMyReactor);
delete pMyReactor;
The following table lists the iterator classes, which provide iterators over collections of objects that import-export functions return or take. The AcMapIEExpressionTargetIteratorand AcMapIENameValueIteratorclasses allow you to modify the iterator's underlying collection by adding, updating, and deleting elements, whereas the other classes iterate over fixed collections. The global functionsAcMapExportFormatIterator()andAcMapImportFormatIterator()return the export-format and import-format iterators, respectively.
Class | Iterates over a collection of |
---|---|
AcMapIEColumnIterator | AcMapIEColumn instances |
AcMapIEExpressionTargetIterator | Expression-target pairs |
AcMapIEFormatIterator | AcMapIEFormat instances |
AcMapIEInputLayerIterator | AcMapIEInputLayer instances |
AcMapIENameValueIterator | Name-value pairs |
For
import-export source-code samples, see
Many functions in the various import-export classes return an AcMapIE::ErrCode error code. When a particular function returns an error code, read that function's documentation for function-specific error conditions rather than relying on only the generic error descriptions in the AcMapIE::ErrCode documentation.
- For more information about importing and exporting maps in AutoCAD Map 3D, choose Help > AutoCAD Map 3D Help > Contents tab (or press F1), and then navigate to Using AutoCAD Map 3D (by feature) > Importing and Exporting Maps.
- For an import-export tutorial in AutoCAD Map 3D, choose Help > Tutorials > Contents tab, and then choose "Importing and Exporting Data".
To view code samples of import-export functions, open the Samples folder in your AutoCAD Map 3D ObjectARX installation and navigate to Map Samples\ImportExport.
Import-Export Classes, Namespaces, and Globals
To view the import-export classes, namespaces, and globals, click the following links:
AcMapIEColumn Class AcMapIEColumnIterator Class AcMapIEExporter Class AcMapIEExportReactor Class AcMapIEExpressionTargetIterator Class AcMapIEFormat Class AcMapIEFormatIterator Class AcMapIEImporter Class AcMapIEImportReactor Class AcMapIEInputLayer Class AcMapIEInputLayerIterator Class AcMapIENameValueIterator Class AcMapIE Namespace AcMapExporter Global Function AcMapExportFormatIterator Global Function AcMapImporter Global Function AcMapImportFormatIterator Global Function