AutoCAD Map 3D Developer

AutoCAD Map 3D Developer

Reply
Contributor
hokrm
Posts: 13
Registered: ‎06-14-2009
Message 1 of 2 (219 Views)

Problem with reading ObjectData via AcDbDatabase

219 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
scradams
Posts: 13
Registered: ‎06-09-2009
Message 2 of 2 (143 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.

 

Thanks,

Jamie

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.