The following code sample illustrates exporting data from a project drawing to an Oracle Spatial database.
Note The sample assumes an open project drawing containing some objects. It also assumes that the connection object is actually connected to a database. Click "Connecting to an Oracle Spatial Database" for sample code.
Connecting to an Oracle Spatial Database (sample)
Exporting data (overview)
Related samples
#include "StdAfx.h" #include "StdArx.h" #include "AcMapOracleConnection.h" #include "AcMapOracleExport.h" BOOL ExportToOracle() { // Get the connection object AcMapOracleConnection *pConnection = AcMapOracleGetConnection(); //Instantiate an export object AcMapOracleExport *pExport = new AcMapOracleExport(pConnection); bool bExport = false; // Export 1 // Default options... // From all layers, export // object data, block attributes, link templates // Erase drawing objects after export bExport = pExport->ExportObjectsAll(); if(bExport) acutPrintf("\nExport 1 successful!!\n"); else acutPrintf("\nExport 1 failed!\n"); // Export 2 // From selected layers 0, Line, and Arc, export // object data, block attributes, link templates // Erase drawing objects after export bExport = pExport->ExportObjectsAll( "0,Line,Arc", AcMapOracleExport::kBlockAttributes | AcMapOracleExport::kObjectData | AcMapOracleExport::kLinkTemplates | AcMapOracleExport::kEraseExported ); if(bExport) acutPrintf("\nExport 2 successful!!\n"); else acutPrintf("\nExport 2 failed!\n"); // Export 3 // From all layers export all objects, but not // object data, block attributes, link templates // With erased objects, delete corresponding record // Erase drawing objects after export bExport = pExport->ExportObjectsAll( "*", AcMapPracleExport::kUpdateErased | AcMapPracleExport::kEraseExported ); if(bExport) acutPrintf("\nExport 3 successful!!\n"); else acutPrintf("\nExport 3 failed!\n"); // Export 4 // Export objects in an ObjectIdArray AcDbObjectIdArray idArray; // idArray can be filled by manually // selecting Objects from Model space // or iterating thorough Model Space // and selecting all bExport = pExport->ExportObjects( idArray, AcMapPracleExport::kBlockAttributes | AcMapPracleExport::kObjectData | AcMapPracleExport::kLinkTemplates | AcMapPracleExport::kEraseExported ); if(bExport) acutPrintf("\nExport 4 successful!!\n"); else acutPrintf("\nExport 4 failed!\n"); // Export 5 // Insert new rows in database (objects are new) // From all layers export all objects, and include // object data, block attributes, link templates // Erase drawing objects after export bExport = pExport->ExportObjects( "*", AcMapPracleExport::kDisregardIDs | AcMapPracleExport::kBlockAttributes | AcMapPracleExport::kObjectData | AcMapPracleExport::kLinkTemplates | AcMapPracleExport::kEraseExported ); if(bExport) acutPrintf("\nExport 5 successful!!\n"); else acutPrintf("\nExport 5 failed!\n"); }