本帖最后由 作者 于 2005-1-25 17:22:15 编辑
static void ExtractAttributes() { ads_name ename; ads_point pt; if(ads_entsel("\nSelect an block: ", ename, pt) != RTNORM) { ads_printf("\nError selecting entity."); return; } AcDbObjectId eId; acdbGetObjectId(eId, ename); AcDbEntity* pEnt = NULL; if (acdbOpenObject(pEnt, eId , AcDb::kForRead) != Acad::eOk) { ads_printf("\nError opening entity."); if(pEnt) pEnt->close(); return; } if(pEnt->isA() != AcDbBlockReference::desc()) { ads_printf("\nMust select a block insert."); pEnt->close(); return; } AcDbBlockReference *pBlkRef = AcDbBlockReference::cast(pEnt); AcDbAttribute *pAtt = NULL; AcDbObjectIterator *pAttIter = pBlkRef->attributeIterator(); _TCHAR tagName[33], strValue[256]; for (pAttIter->start(); !pAttIter->done(); pAttIter->step()) { acdbOpenObject(pAtt, pAttIter->objectId(), AcDb::kForRead); // get the tag string _tcscpy(tagName, pAtt->tag()); ads_printf("\nBlock Insert Attribute tag is: %s", tagName); _tcscpy(strValue, pAtt->textString()); ads_printf("\nBlock Insert Attribute string value is: %s", strValue); pAtt->close(); } delete pAttIter; pBlkRef->close(); } |