找回密码
 立即注册

QQ登录

只需一步,快速开始

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

OBJECT ARX 实体类的炸开,求交,外包矩形函数使用

[复制链接]

1

主题

0

回帖

37

积分

管理员

积分
37
发表于 2024-5-2 22:45:34 | 显示全部楼层 |阅读模式
  1. //==============炸开============
  2. static void TESTzhakaicmd()
  3. {
  4. // Add your code for command ahlzlARX.采用test here
  5. ads采用name ent;
  6. ads采用point pt;
  7. if (acedEntSel(采用T("\n请选择对象:"), ent, pt) != RTNORM)
  8. {
  9.   return;
  10. }
  11. AcDbObjectId entId;
  12. acdbGetObjectId(entId, ent);
  13. AcDbEntity *pEnt = NULL;
  14. acdbOpenObject(pEnt, entId, AcDb::kForWrite);
  15. AcDbVoidPtrArray pExps;
  16. if (pEnt->explode(pExps) == Acad::eOk)
  17. {
  18.   for (int i = 0; i < pExps.length(); i++)
  19.   {
  20.    AcDbEntity *pExpEnt = (AcDbEntity*)pExps[i];
  21.    acutPrintf(采用T("\n分解后的对象类型名是: %s"), (pExpEnt->isA()->name()));
  22.    LoadEntity(pExpEnt);
  23.   }
  24.   pEnt->erase(true);
  25. }
  26. else
  27. {
  28.   acutPrintf(采用T("\n该对象不能被分解!"));
  29. }
  30. pEnt->close();
  31. }
  32. //选择两个对象,求交点;如果选了域,输出面积
  33. static void TESTintersactcmd(){
  34. ads采用name ent1;
  35. ads采用point pt1;
  36. if (acedEntSel(采用T("\n请选择对象1:"), ent1, pt1) != RTNORM)
  37. {
  38.   return;
  39. }
  40. AcDbObjectId entId1;
  41. acdbGetObjectId(entId1, ent1);
  42. AcDbEntity *pEnt1 = NULL;
  43. acdbOpenObject(pEnt1, entId1, AcDb::kForWrite);
  44. ads采用name ent2;
  45. ads采用point pt2;
  46. if (acedEntSel(采用T("\n请选择对象2:"), ent2, pt2) != RTNORM)
  47. {
  48.   return;
  49. }
  50. AcDbObjectId entId2;
  51. acdbGetObjectId(entId2, ent2);
  52. AcDbEntity *pEnt2 = NULL;
  53. acdbOpenObject(pEnt2, entId2, AcDb::kForWrite);
  54. AcGePoint3dArray ptArr;
  55. pEnt1->intersectWith(pEnt2,AcDb::Intersect::kOnBothOperands,ptArr);
  56. CString outStr;
  57. outStr.Format(采用T("交集点的数量:%d"),ptArr.length());
  58. acutPrintf(outStr);
  59. if(pEnt1->isKindOf(AcDbRegion::desc())){
  60. AcDbRegion* r = (AcDbRegion*)pEnt1;
  61. double area;
  62. r->getArea(area);
  63. CString str;
  64. str.Format(采用T("\n面积:%.2f"),area);
  65. r->close();
  66. }
  67. pEnt1->close();
  68. pEnt2->close();
  69. }
  70. 外包矩形,返回外接矩形的两个端点
  71. static void TESTgeocmd(){
  72. ads采用name ent;
  73. ads采用point pt;
  74. if (acedEntSel(采用T("\n请选择对象:"), ent, pt) != RTNORM)
  75. {
  76.   return;
  77. }
  78. AcDbObjectId entId;
  79. acdbGetObjectId(entId, ent);
  80. AcDbEntity *pEnt = NULL;
  81. acdbOpenObject(pEnt, entId, AcDb::kForWrite);
  82. AcDbExtents extent;
  83. Acad::ErrorStatus es = pEnt->getGeomExtents(extent);
  84. if(es == Acad::ErrorStatus::eOk){
  85. AcGePoint3d ptMin = extent.minPoint();
  86. AcGePoint3d ptMax = extent.maxPoint();
  87. CString str;
  88. str.Format(采用T("\nx1:%.2f ,y1:%.2f, z1:%.2f \nx2: %.2f,y2: %.2f, z2: %.2f"),ptMin[X],ptMin[Y],ptMin[Z],ptMax[X],ptMax[Y],ptMax[Z]);
  89. acutPrintf(str);
  90. }
  91. }
  92. 2
复制代码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-1-4 12:18 , Processed in 0.126609 second(s), 21 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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