Acad::ErrorStatus ArxDbgUtils::symbolIdToName(const AcDbObjectId& symbolId, CString& name) { // shouldn't happen usually, but some debugging routines // want to print out this info if (symbolId == AcDbObjectId::kNull) { name = _T("AcDbObjectId::kNull"); return Acad::eNullObjectId; } // get symbol name from symbol table record AcDbSymbolTableRecord* tblRec; Acad::ErrorStatus es; es = acdbOpenObject(tblRec, symbolId, AcDb::kForRead); if (es == Acad::eOk) { const TCHAR* locName; tblRec->getName(locName); name = locName; tblRec->close(); } else { ArxDbgUtils::rxErrorMsg(es); es = Acad::eInvalidInput; } return es; }
bool purgeSymbolTable(AcRxClass* pTableClass) { CLogger::Print(_T("*Call: purgeSymbolTable()")); Acad::ErrorStatus es; AcDbObjectIdArray idaAll; getAllSymbolRecordsIds(pTableClass, idaAll); //------------ // Filter SymbolTableRecord's ObjectIds that need to purge. AcDbDatabase* pDb = acdbHostApplicationServices()->workingDatabase(); es = pDb->purge(idaAll); if (Acad::eOk != es) { CLogger::Print(_T("*Exit: purgeSymbolTable() - Fail to get the ObjectIds that need to purge!")); return false; } //------------ // If the kind of SymbolTable is AcDbLayerTable, Unlock all its records. CAllLayerState stateLayers; if (AcRx::kEqual == pTableClass->comparedTo(AcDbLayerTable::desc())) { stateLayers.memorize(pDb); stateLayers.unlock(); } int nLength = idaAll.length(); if (nLength <= 0) { CLogger::Print(_T("*Exit: purgeSymbolTable() - There is nothing to purge!")); return false; } //------------ // Steps through the SymbolTableRecords for (int nIndex = 0; nIndex < nLength; nIndex++) { AcDbSymbolTableRecord* pSymbolTableRecord = NULL; if (Acad::eOk != acdbOpenObject(pSymbolTableRecord, idaAll[nIndex], AcDb::kForWrite)) { CLogger::Print(_T("Warn: Fail to get SymbolTableRecord! > Ignore")); continue; } // Get SymbolTableRecord's name (just for informing) const ACHAR* szRecordName; if (Acad::eOk != pSymbolTableRecord->getName(szRecordName)) { CLogger::Print(_T("Warn: Fail to get the Record's name! > Ignore")); pSymbolTableRecord->close(); continue; } // Erase the SymbolTableRecord. if (Acad::eOk != pSymbolTableRecord->erase(Adesk::kTrue)) { CLogger::Print(_T("Warn: Fail to erase SymbolTableRecord named '%s'! > Ignore"), szRecordName); pSymbolTableRecord->close(); continue; } CLogger::Print(_T("Inform: SymbolTableRecord '%s' has been erased."), szRecordName); pSymbolTableRecord->close(); } //------------ // If the kind of SymbolTable is AcDbLayerTable, restore all its records states. if (AcRx::kEqual == pTableClass->comparedTo(AcDbLayerTable::desc())) { stateLayers.remember(); } CLogger::Print(_T("*Exit: purgeSymbolTable()")); return true; }