|
AcDbSortentsTable * getSortentsTable(AcDbBlockTableRecord * pRec)
{
if (!pRec)
return NULL;
Acad::ErrorStatus es;
AcDbObjectId ext_id = pRec->extensionDictionary();
if (AcDbObjectId::kNull == ext_id)
{
pRec->upgradeOpen();
es = pRec->createExtensionDictionary();
if (es != eOk)
return NULL;
pRec->downgradeOpen();
ext_id = pRec->extensionDictionary();
if (AcDbObjectId::kNull == ext_id)
{
return NULL;
}
pRec->downgradeOpen();
}
AcDbDictionary *pExt;
es = acdbOpenObject(pExt, ext_id, AcDb::kForRead);
if (Acad::eOk != es)
return NULL;
AcDbObject *pObj;
if (Acad::eOk != pExt->getAt(_T("ACAD_SORTENTS"), pObj, AcDb::kForWrite))
{
if (Acad::eOk != pExt->upgradeOpen())
{
pExt->close();
return NULL;
}
AcDbSortentsTable *pSt = new AcDbSortentsTable;
if (NULL == pSt)
{
pExt->close();
return NULL;
}
AcDbObjectId new_id;
if (Acad::eOk != pExt->setAt(_T("ACAD_SORTENTS"), pSt, new_id))
{
delete pSt;
pExt->close();
return NULL;
}
pSt->setBlockId(pRec->objectId());
pObj = pSt;
}
pExt->close();
if (!pObj->isKindOf(AcDbSortentsTable::desc()))
{
pObj->close();
return NULL;
}
return (AcDbSortentsTable*)pObj;
} |
|