AutoCAD Map 3D Developer

AutoCAD Map 3D Developer

Reply
Contributor
13 Posts
0 Kudos
Registered: ‎06-14-2009
Post 1 of 2

Problem with reading ObjectData via AcDbDatabase

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

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
Contributor
13 Posts
1 Kudo
Registered: ‎06-09-2009
Post 2 of 2

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.

 

Thanks,

Jamie

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!