天气与日历 切换到窄版

 找回密码
 立即注册
中国膜结构网
十大进口膜材评选 十大国产膜材评选 十大膜结构设计评选 十大膜结构公司评选
查看: 141|回复: 0

[每日一码] 如何把其他对象的OBJECTID保存到扩展词典的扩展记录中

[复制链接]
  • TA的每日心情
    开心
    半小时前
  • 签到天数: 20 天

    [LV.4]偶尔看看III

    115

    主题

    11

    回帖

    1393

    积分

    管理员

    积分
    1393
    QQ
    发表于 2024-3-14 20:58:18 | 显示全部楼层 |阅读模式
    1. int AddSoftpointerIntoXdict(AcDbObjectId id1,AcDbObjectId id2)
    2. {
    3. Acad::ErrorStatus retStat;
    4. AcDbXrecord * pXrec=new AcDbXrecord;
    5. AcDbDictionary *pDict=NULL;
    6. AcDbObjectId dictid,xrecid;
    7. AcDbSoftPointerId SP(id2);
    8. AcDbObject * pobj;
    9. struct resbuf * head=NULL;
    10. ads采用name adsName;
    11. if((retStat=acdbOpenObject(pobj,id1,AcDb::kForWrite))!=
    12.   Acad::eOk)
    13.   return 0;
    14. pobj->createExtensionDictionary();
    15. dictid=pobj->extensionDictionary();
    16. pobj->close();
    17. acdbOpenObject(pDict,dictid,AcDb::kForWrite);
    18. pDict->setAt(采用T("TEST"),pXrec,xrecid);
    19. pDict->close();
    20. acdbGetAdsName(adsName, id2);
    21. head=acutBuildList(AcDb::kDxfSoftPointerId, adsName, 0);
    22. pXrec->setFromRbChain(* head);
    23. pXrec->close();
    24. acutRelRb(head);
    25. return 1;
    26. }
    27. void AddInfo()
    28. {
    29. int rt;
    30. ads采用name en1,en2;
    31. ads采用point pickpt;
    32. AcDbObjectId id1, id2;
    33. Acad::ErrorStatus retStat;
    34. rt=acedEntSel(
    35.   采用T("\nSelect an entity to reference the following entity: "),
    36.   en1,pickpt);
    37. if(rt!=RTNORM)
    38.   return;
    39. retStat=acdbGetObjectId(id1,en1);
    40. assert(retStat==Acad::eOk);
    41. rt=acedEntSel(采用T("\nSelect an entity to be referenced: "),
    42.   en2,pickpt);
    43. if(rt!=RTNORM)
    44.   return;
    45. retStat=acdbGetObjectId(id2,en2);
    46. assert(retStat==Acad::eOk);
    47. acutPrintf(采用T("\nid2=%ld"),id2);
    48. rt=AddSoftpointerIntoXdict(id1,id2);
    49. if(rt==0)
    50.   return;
    51. }
    52. [it618postdisplay>0]
    53. 普通浏览复制代码
    54. void GetInfo()
    55. {
    56. int rt;
    57. ads采用name en1;
    58. ads采用point pickpt;
    59. AcDbObjectId id1;
    60. Acad::ErrorStatus retStat;
    61. AcDbXrecord * pXrec=NULL;
    62. AcDbDictionary * pDict;
    63. AcDbObjectId dictid,xrecid;
    64. struct resbuf * rb;
    65. AcDbObjectId tmpId=NULL;
    66. rt=acedEntSel(
    67.   采用T("\nSelect an entity attached extension dictionary:"),
    68.   en1,pickpt);
    69. if(rt!=RTNORM)
    70.   return;
    71. retStat=acdbGetObjectId(id1,en1);
    72. assert(retStat==Acad::eOk);
    73. AcDbObject * pobj;
    74. retStat=acdbOpenObject(pobj,id1,AcDb::kForRead);
    75. assert(retStat==Acad::eOk);
    76. dictid=pobj->extensionDictionary();
    77. if(dictid==AcDbObjectId::kNull)
    78. {
    79.   acutPrintf(采用T("\nId is NULL."));
    80.   pobj->close();
    81.   return;
    82. }
    83. pobj->close();
    84. acdbOpenObject(pDict,dictid,AcDb::kForRead);
    85. pDict->getAt(采用T("TEST"),(AcDbObject * &)pXrec,AcDb::kForRead);
    86. pDict->close();
    87. pXrec->rbChain(&rb);
    88. pXrec->close();
    89. if(rb==NULL)
    90.   acutPrintf(采用T("\nNull result buffer."));
    91. if (rb->restype == AcDb::kDxfSoftPointerId)
    92. {
    93.   acdbGetObjectId(tmpId, rb->resval.rlname);
    94.   acutPrintf(采用T("\nReferenced Id=%ld"),tmpId);
    95. }
    96. acutRelRb(rb);
    97. }
    复制代码

     

     

     

     

    [每日一码] 如何把其他对象的OBJECTID保存到扩展词典的扩展记录中
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|Archiver|中国膜结构网|中国膜结构协会|进口膜材|国产膜材|ETFE|PVDF|PTFE|设计|施工|安装|车棚|看台|污水池|中国膜结构网_中国空间膜结构协会

    GMT+8, 2024-11-5 06:02 , Processed in 0.155547 second(s), 26 queries .

    Powered by Discuz! X3.5

    © 2001-2024 Discuz! Team.

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