|
遍历指定动态块的所有可见性名称方法(二)
依然采用了entget dxf大法
- ads_name ent;
- ads_point pt;
- if(RTNORM != acedEntSel(NULL,ent,pt))
- {
- acutPrintf(_T("\n未选择到对象!"));
- return;
- }
- AcDbObjectId objId;
- acdbGetObjectId(objId,ent);
- AcDbObjectPointer<AcDbBlockReference> pBlkRef(objId,AcDb::kForRead);
- if(Acad::eOk != pBlkRef.openStatus())
- {
- acutPrintf(_T("\n打开块参照失败!"));
- return;
- }
- AcDbDynBlockReference dynBlkRef(objId);
- if(!dynBlkRef.isDynamicBlock())
- {
- acutPrintf(_T("\n非动态块参照!"));
- return;
- }
- AcDbObjectId blkDefId=dynBlkRef.dynamicBlockTableRecord();
- AcDbBlockTableRecordPointer pBlkDef(blkDefId,AcDb::kForRead);
- if(Acad::eOk != pBlkDef.openStatus())
- {
- acutPrintf(_T("\n块定义打开失败!"));
- return;
- }
- AcDbObjectId dicId= pBlkDef->extensionDictionary();
- AcDbObjectPointer<AcDbDictionary> pDic(dicId,AcDb::kForRead);
- if(Acad::eOk != pDic.openStatus())
- {
- acutPrintf(_T("\n扩展词典打开失败!"));
- return;
- }
- AcDbObjectId enhancedblkId;
- pDic->getAt(_T("ACAD_ENHANCEDBLOCK"),enhancedblkId);
- AcDbObjectPointer<AcDbEvalGraph> pEnhancedBlk(enhancedblkId,AcDb::kForRead);
- if(Acad::eOk != pEnhancedBlk.openStatus())
- {
- acutPrintf(_T("\nACAD_ENHANCEDBLOCK打开失败!"));
- return;
- }
- AcDbEvalNodeIdArray nodeIdArray;
- pEnhancedBlk->getAllNodes(nodeIdArray);
- for(int i=0;i<nodeIdArray.length();i++)
- {
- AcDbEvalNodeId subId=nodeIdArray.at(i);
- AcDbObject *pNode=NULL;
- pEnhancedBlk->getNode(subId,AcDb::kForRead,&pNode);
- if(pNode == NULL) continue;
- if(pNode->isKindOf(AcDbEvalExpr::desc()))
- {
- CString strDxfName=pNode->objectId().objectClass()->dxfName();
- if (_T("BLOCKVISIBILITYPARAMETER") == strDxfName)
- {
- ads_name nodeEnt;
- Acad::ErrorStatus es= acdbGetAdsName(nodeEnt,pNode->objectId());
- resbuf *elist= acdbEntGet(nodeEnt);
- if (elist!=NULL)
- {
- for (resbuf *eb = elist; eb != NULL; eb = eb->rbnext)
- {
- if (eb->restype == 301)
- {
- printdxf(eb);
- }
- else if (eb->restype == 303)
- {
- printdxf(eb);
- }
- }
- acutRelRb(elist);
- }
- }
-
- }
- pNode->close();
- }
复制代码 |
|