明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2921|回复: 2

AcDbDynBlockReferenceProperty学习~

[复制链接]
发表于 2014-12-4 16:53:06 | 显示全部楼层 |阅读模式
本帖最后由 Arthas 于 2014-12-4 16:55 编辑

AcDbDynBlockReferenceProperty:
  1.     ads_name  ent;
  2.     ads_point sltpt;

  3.     int ret;
  4.     Acad::ErrorStatus es;
  5.     ret=acedEntSel(_T("\n Selct BlockReference:"), ent,sltpt);
  6.     if (RTNORM!=ret)
  7.     {
  8.       acedAlert(_T("NotSelect"));
  9.       return;
  10.     }

  11.     AcDbObjectId DynBlkId;
  12.     es=acdbGetObjectId(DynBlkId,ent);
  13.     if (Acad::eOk!=es)
  14.     {
  15.       acedAlert(_T("Failed to get entity's ID!"));
  16.       return;
  17.     }


  18.     AcDbDynBlockReference dynblkRef(DynBlkId);
  19.     //////////////////////blkName////////
  20.     AcDbObject* pObj; es = acdbOpenAcDbObject(pObj, DynBlkId  , AcDb::kForRead);
  21.     AcDbBlockReference *Reference=AcDbBlockReference::cast(pObj);           
  22.     AcDbObjectId refId=Reference->blockTableRecord();        
  23.     AcDbBlockTableRecord* pBlkTableRec; es=acdbOpenObject(pBlkTableRec,refId,AcDb::kForRead);     
  24.     if(es != Acad::eOk) {acutPrintf(_T("BlockTableRec Open  Error?????")); return;}
  25.     const ACHAR* Name; es = pBlkTableRec->getName(Name);
  26.     acutPrintf(_T("Name %s"),Name);
  27.     pObj->close();
  28.    
  29.     ////////////////////////////DynBlkName///////
  30. AcDbObjectId  blockRecordId=   dynblkRef.dynamicBlockTableRecord ();
  31. es = acdbOpenAcDbObject(pObj, blockRecordId  , AcDb::kForRead);
  32. if (es != Acad::eOk) {acutPrintf(_T("dynBlock Table Rec Open  Error")); return;}   
  33. AcDbBlockTableRecord* blkTblRec = AcDbBlockTableRecord::cast(pObj);   
  34. ACHAR *effectiveName;
  35. es=blkTblRec->getName(effectiveName);
  36. if(es!= Acad::eOk) return;
  37. acutPrintf(_T("\n Effective Name %s"),effectiveName);
  38. pObj->close();
  39. ///////////
  40. if (!dynblkRef.isDynamicBlock())
  41. {
  42.   acedAlert(_T("It is not dynamic block reference!"));
  43.   return;
  44. }
  45. acutPrintf(_T("\nIt is dynamic block!"));
  46. AcDbDynBlockReferencePropertyArray propArr;
  47. dynblkRef.getBlockProperties(propArr);
  48. acutPrintf(_T("\nThere are %d properities!"),propArr.length());
  49. for (int i=0;i<propArr.length();++i)
  50. {
  51.   AcDbDynBlockReferenceProperty prop1=propArr.at(i);
  52. AcDbEvalVariant evalvar=prop1.value();
  53. CString strEvalType;
  54. CString strEval;     
  55. acutPrintf(_T("\n\n Restype %d"),evalvar.restype);
  56. switch (evalvar.restype)
  57.   {   
  58. case 70:// см. dxfcod (entget)
  59.    strEvalType=_T("int");   
  60.     strEval.Format(_T("%d"),evalvar.resval.rint);//
  61.    break;
  62.   case 40 ://
  63.    strEvalType=_T("Double");
  64.    strEval.Format(_T("%g"),evalvar.resval.rreal);
  65.    break;
  66.   case 11  : //
  67.   strEvalType=_T("Point2d");
  68.    strEval.Format(_T("(%.5f,%.5f,0)"),
  69.     evalvar.resval.rpoint[0],
  70.        evalvar.resval.rpoint[1]);
  71.    break;
  72.   case 1 : //
  73.    strEvalType=_T("String");
  74.    strEval.Format(_T("%s"),evalvar.resval.rstring);
  75.    break;
  76.   default : // e.t.c
  77.       strEvalType=_T("unknown");  
  78.   }   
  79.   acutPrintf(_T("\nproperty : %d"),i+1);
  80.   acutPrintf(_T("\n      Name:%s"),prop1.propertyName().constPtr());
  81.   acutPrintf(_T("\n      Description : %s"),prop1.description().constPtr());
  82.   acutPrintf(_T("\n      Value Type= %s"),strEvalType);
  83.   acutPrintf(_T("\n      Value = %s\n"),strEval);  


  84. }




发表于 2014-12-5 08:54:12 | 显示全部楼层
厉害,学习了
发表于 2014-12-23 08:54:51 | 显示全部楼层
刚路过,见一回顶一回
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-25 06:55 , Processed in 0.134222 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表