找回密码
 立即注册

QQ登录

只需一步,快速开始

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

arx 获取三维实体边、面,并高亮

[复制链接]

1

主题

0

回帖

37

积分

管理员

积分
37
发表于 2024-5-4 18:13:31 | 显示全部楼层 |阅读模式
  1. void
  2. highlightEdge(const AcDbObjectId& objId, const int marker)
  3. {
  4.     TCHAR dummy[133]; // space for acedGetStringB pauses below
  5.     AcDbEntity *pEnt;
  6.     acdbOpenAcDbEntity(pEnt, objId, AcDb::kForRead);
  7.     AcGePoint3d pickpnt;
  8.     AcGeMatrix3d xform;
  9.     int numIds;
  10.     AcDbFullSubentPath *subentIds;
  11.     pEnt->getSubentPathsAtGsMarker(AcDb::kEdgeSubentType,
  12.         marker, pickpnt, xform, numIds, subentIds);
  13.     // At this point the subentId's variable contains the
  14.     // address of an array of AcDbFullSubentPath objects.
  15.     // The array should be one element long, so the picked
  16.     // edge's AcDbFullSubentPath is in subentIds[0].
  17.     //
  18.     // For objects with no edges (such as a sphere), the
  19.     // code to highlight an edge is meaningless and must
  20.     // be skipped.
  21.     //
  22.     if (numIds > 0) {
  23.         // Highlight the edge.
  24.         //
  25.         pEnt->highlight(subentIds[0]);
  26.         // Pause to let user see the effect.
  27.         //
  28.         acedGetString(0, 采用T("\npress <RETURN> to continue..."),
  29.             dummy);
  30.         // Unhighlight the picked edge.
  31.         //
  32.         pEnt->unhighlight(subentIds[0]);
  33.         // Get a copy of the edge, and add it to the database.
  34.         //
  35.         AcDbEntity *pEntCpy = pEnt->subentPtr(subentIds[0]);
  36.         AcDbObjectId objId;
  37.         addToModelSpace(objId, pEntCpy);
  38.     }
  39.     delete []subentIds;
  40.     pEnt->close();
  41. }
  42. void
  43. highlightFaces(const AcDbObjectId& objId, const int marker)
  44. {
  45.     TCHAR dummy[133];
  46.     AcDbEntity *pEnt;
  47.     acdbOpenAcDbEntity(pEnt, objId, AcDb::kForRead);
  48.     // Get the subentIds for the faces.
  49.     //
  50.     AcGePoint3d pickpnt;
  51.     AcGeMatrix3d xform;
  52.     int numIds;
  53.     AcDbFullSubentPath *subentIds;
  54.     pEnt->getSubentPathsAtGsMarker(AcDb::kFaceSubentType,
  55.         marker, pickpnt, xform, numIds, subentIds);
  56.     // Walk the subentIds list, highlighting each face subentity.
  57.     //
  58.     for (int i = 0;i < numIds; i++) {
  59.         pEnt->highlight(subentIds[i]); // Highlight face.
  60.         // Pause to let the user see the effect.
  61.         //
  62.         acedGetString(0, 采用T("\npress <RETURN> to continue..."),
  63.             dummy);
  64.         pEnt->unhighlight(subentIds[i]);
  65.     }
  66.     delete []subentIds;
  67.     pEnt->close();
  68. }
  69. void
  70. highlightAll(const AcDbObjectId& objId)
  71. {
  72.     TCHAR dummy[133];
  73.     AcDbEntity *pEnt;
  74.     acdbOpenAcDbEntity(pEnt, objId, AcDb::kForRead);
  75.     // Highlight the whole solid.
  76.     //
  77.     pEnt->highlight();
  78.     // Pause to let user see the effect.
  79.     //
  80.     acedGetString(0, 采用T("\npress <RETURN> to continue..."),
  81.         dummy);
  82.     pEnt->unhighlight();
  83.     pEnt->close();
  84. }
  85. Acad::ErrorStatus
  86. addToModelSpace(AcDbObjectId &objId, AcDbEntity* pEntity)
  87. {
  88.     AcDbBlockTable *pBlockTable;
  89.     AcDbBlockTableRecord *pSpaceRecord;
  90.     acdbHostApplicationServices()->workingDatabase()
  91.         ->getSymbolTable(pBlockTable, AcDb::kForRead);
  92.     pBlockTable->getAt(ACDB采用MODEL采用SPACE, pSpaceRecord,
  93.         AcDb::kForWrite);
  94.     pSpaceRecord->appendAcDbEntity(objId, pEntity);
  95.     pBlockTable->close();
  96.     pEntity->close();
  97.     pSpaceRecord->close();
  98.     return Acad::eOk;
  99. }
复制代码
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-1-4 13:27 , Processed in 0.108720 second(s), 21 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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