AutoCAD Map 3D Developer
Welcome to Autodesk’s AutoCAD Map 3D Developer Forums. Share your knowledge, ask questions, and explore popular AutoCAD Map 3D Developer topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Problem with reading ObjectData via AcDbDatabase

1 REPLY 1
Reply
Message 1 of 2
hokrm
437 Views, 1 Reply

Problem with reading ObjectData via AcDbDatabase

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 !");

acedPrompt(m_strErr);

}

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;

pBlockTableRecord->Close();

delete pDatabase; Edited by: hokrm on Jun 15, 2009 8:47 AM
1 REPLY 1
Message 2 of 2
scradams
in reply to: hokrm

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

 

Thanks,

Jamie

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost