以下代码实现自定义属性块的属性值提取,我采用鼠标拾取的方式从打开的图形文件中指定块(注意块中要有自己定义的属性)注释部分代码是我基于ACUI对话框实现的,根据你的具体情况选择吧 // BeginEditorCommand(); //ShowWindow(SW_HIDE); ads_name adsNameBlockRef; ads_name entRes; ads_point ptRes; ads_matrix xFormRes; struct resbuf *refStkRes, *eb; if(acedNEntSelP(NULL,entRes,ptRes,FALSE,xFormRes,&refStkRes) == RTNORM) { for(eb = refStkRes; eb != NULL;eb = eb->rbnext) { ads_name_set(eb->resval.rlname,adsNameBlockRef); } acutRelRb(refStkRes); // CompleteEditorCommand(); } else { // CancelEditorCommand(); } //ShowWindow(SW_SHOW); AcDbObjectId blkRefId; acdbGetObjectId(blkRefId, adsNameBlockRef); AcDbBlockReference *pBlkRef; acdbOpenObject(pBlkRef, blkRefId, AcDb::kForRead); AcDbObjectIterator *pAttrIter = pBlkRef->attributeIterator(); pBlkRef->close(); char *pStr = ""; char *pText = ""; AcDbAttribute *pAttr; AcDbObjectId attrObjId; for(int attrNumber = 0; !pAttrIter->done(); pAttrIter->step()) { attrObjId = pAttrIter->objectId(); acdbOpenObject(pAttr,attrObjId,AcDb::kForRead); pStr = pAttr->tag(); pText = pAttr->textString(); pAttr->close(); attrNumber++; acutPrintf("\nAttribute %d,Tag %s, Value %s",attrNumber,pStr,pText); } delete pAttrIter; |