[转载]动态块的真实名称EffectiveName
static void sk_ArxProject2getblkname(void) { // Add your code for command sk_ArxProject2.getblkname here ads_name ename; ads_point pt; if (acedEntSel(L"\nSelect a dynamic block reference: ", ename, pt) != RTNORM) { acutPrintf(L"\nError selecting entity."); return; } AcDbObjectId eId; acdbGetObjectId(eId, ename); AcDbEntity* pEnt = NULL; if (acdbOpenObject(pEnt, eId, AcDb::kForRead) != Acad::eOk) { acutPrintf(L"\nError opening entity."); if (pEnt) pEnt->close(); return; } if (pEnt->isA() != AcDbBlockReference::desc()) { acutPrintf(L"\nMust select a block insert."); pEnt->close(); return; } AcDbBlockReference *pBlkRef = AcDbBlockReference::cast(pEnt); // initialise a AcDbDynBlockReference from the object id of the blockreference AcDbDynBlockReference* pDynBlkRef = new AcDbDynBlockReference(pBlkRef->objectId()); //Don't forget to close the blockreference here, otherwise you wont be able to modify properties pEnt->close(); if (pDynBlkRef) { AcDbObjectId idBlkTblRcd= pDynBlkRef->dynamicBlockTableRecord(); AcDbObjectPointer<AcDbBlockTableRecord>pBlkTblRcd(idBlkTblRcd, AcDb::kForRead); if (pBlkTblRcd.openStatus()!=Acad::eOk) { return; } ACHAR* szName = NULL; Acad::ErrorStatus es = pBlkTblRcd->getName(szName); acutPrintf(szName); delete pDynBlkRef; } }
目录 返回
首页