找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz
查看: 140|回复: 0

使用ObjectARX从块插入中提取属性标记字符串

[复制链接]

0

主题

0

回帖

28

积分

管理员

积分
28
发表于 2024-3-14 19:28:22 | 显示全部楼层 |阅读模式
  1. #include <TCHAR.H>
  2. void ExtractAttributes()
  3. {
  4. ads采用name ename;
  5. ads采用point pt;
  6. if(acedEntSel("\nSelect an block: ", ename, pt) != RTNORM)
  7. {
  8.     acutPrintf("\nError selecting entity.");
  9.     return;
  10. }
  11. AcDbObjectId eId;
  12. acdbGetObjectId(eId, ename);
  13. AcDbEntity* pEnt = NULL;
  14. if (acdbOpenObject(pEnt, eId , AcDb::kForRead) != Acad::eOk)
  15. {
  16.     acutPrintf("\nError opening entity.");
  17.     if(pEnt)
  18.       pEnt->close();
  19.     return;
  20. }
  21. if(pEnt->isA() != AcDbBlockReference::desc())
  22. {
  23.     acutPrintf("\nMust select a block insert.");
  24.     pEnt->close();
  25.     return;
  26. }
  27. AcDbBlockReference *pBlkRef = AcDbBlockReference::cast(pEnt);
  28. AcDbAttribute *pAtt = NULL;
  29. AcDbObjectIterator *pAttIter = pBlkRef->attributeIterator();
  30. 采用TCHAR tagName[33], strValue[256];
  31. for (pAttIter->start(); !pAttIter->done(); pAttIter->step())
  32. {
  33.      acdbOpenObject(pAtt, pAttIter->objectId(), AcDb::kForRead);
  34.      // get the tag string
  35.      采用tcscpy(tagName, pAtt->tag());
  36.      acutPrintf("\nBlock Insert Attribute tag is: %s", tagName);
  37.      采用tcscpy(strValue, pAtt->textString());
  38.      acutPrintf("\nBlock Insert Attribute string value is: %s", strValue);
  39.      pAtt->close();
  40. }
  41. delete pAttIter;
  42. pBlkRef->close();
  43. }
复制代码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|膜结构网

GMT+8, 2024-12-29 05:07 , Processed in 0.100412 second(s), 20 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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