AutoCAD Map 3D Developer

AutoCAD Map 3D Developer

Posts: 13
Registered: ‎06-14-2009
Message 1 of 2 (215 Views)

Problem with reading ObjectData via AcDbDatabase

215 Views, 1 Replies
06-14-2009 11:18 PM
Hi all

I have Drawing (Drawing 1.dwg) with some entities and these entities has attached ObjectData. When i open new (empty) dwg file and run my code so i don't get AcMapODTable object. I need to read Column Name of ObjectData, but method pODCont->GetODTable(pODTable, record.ODTableName() return kErrObjectNotFound. I don't know how Can i get Column Name when i open my Dwg files via AcDbDatabase.

thank you all for advice Milan.

AcDbDatabase* pDatabase = new AcDbDatabase(Adesk::kFalse);

if(pDatabase->readDwgFile(L"c:\\dwgTest\\Drawing1.dwg", _SH_DENYNO)!=Acad::eOk) {

m_strErr.Format(L"I can't open the file: c:\\dwgTest\\Drawing1.dwg !");



Acad::ErrorStatus es;

AcDbBlockTable* pBlockTable = NULL;

AcDbBlockTableRecord* pBlockTableRecord = NULL;

es = pDatabase->getSymbolTable(pBlockTable, AcDb::kForRead);

es = pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord, AcDb::kForRead);

es = pBlockTable->close();

AcDbBlockTableRecordIterator *pIterator = NULL;

es = pBlockTableRecord->newIterator(pIterator);

for(pIterator->start(); !pIterator->done(); pIterator->step()) {

AcMap::EErrCode ec;

Adesk::Boolean AdeskBoolean;

AcMapSession *mapApi = NULL;

cMapProject *pProj = NULL;

AcMapODContainer *pODCont = NULL;

AcMapODTable *pODTable = NULL;

mapApi = AcMapGetSession();

AdeskBool = mapApi->GetProject(pProj);

AdeskBool = pProj->GetODContainer(pODCont);

AcDbObjectId eId;

AcMapODRecordIterator* pTableIterator = NULL;

ec = pODCont->GetObjectODRecordIterator(pTableIterator);

es = pIterator->getEntityId(eId);

ec = pTableIterator->Init(eId, AcMap::kOpenForRead, Adesk::kFalse);

for(; pTableIterator->IsDone() == Adesk::kFalse; pTableIterator->Next()) {

AcMapODTableRecord record;

ec = pTableIterator->GetRecord(record);

ec = pODCont->GetODTable(pODTable, record.ODTableName());

if(ec == AcMap::kOk) {

AcMapODTableDefinition TabDef;

AcMapODColumnDefinition ColDef;

TabDef = pODTable->Definition();

for(int i = 0; i<TabDef.Count(); i++) {

TabDef.GetColumn(ColDef, i);

CString ColumnName = ColDef.Name();




delete pODTable;

delete pTableIterator;


delete pIteretator;


delete pDatabase; Edited by: hokrm on Jun 15, 2009 8:47 AM
Active Member
Posts: 7
Registered: ‎06-09-2009
Message 2 of 2 (139 Views)

Re: Problem with reading ObjectData via AcDbDatabase

10-23-2012 07:41 AM in reply to: hokrm

Did you ever find a solution to this? I'm trying to do the same thing.




Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.