arx 获取三维实体边、面,并高亮
voidhighlightEdge(const AcDbObjectId& objId, const int marker)
{
TCHAR dummy; // space for acedGetStringB pauses below
AcDbEntity *pEnt;
acdbOpenAcDbEntity(pEnt, objId, AcDb::kForRead);
AcGePoint3d pickpnt;
AcGeMatrix3d xform;
int numIds;
AcDbFullSubentPath *subentIds;
pEnt->getSubentPathsAtGsMarker(AcDb::kEdgeSubentType,
marker, pickpnt, xform, numIds, subentIds);
// At this point the subentId's variable contains the
// address of an array of AcDbFullSubentPath objects.
// The array should be one element long, so the picked
// edge's AcDbFullSubentPath is in subentIds.
//
// For objects with no edges (such as a sphere), the
// code to highlight an edge is meaningless and must
// be skipped.
//
if (numIds > 0) {
// Highlight the edge.
//
pEnt->highlight(subentIds);
// Pause to let user see the effect.
//
acedGetString(0, 采用T("\npress <RETURN> to continue..."),
dummy);
// Unhighlight the picked edge.
//
pEnt->unhighlight(subentIds);
// Get a copy of the edge, and add it to the database.
//
AcDbEntity *pEntCpy = pEnt->subentPtr(subentIds);
AcDbObjectId objId;
addToModelSpace(objId, pEntCpy);
}
delete []subentIds;
pEnt->close();
}
void
highlightFaces(const AcDbObjectId& objId, const int marker)
{
TCHAR dummy;
AcDbEntity *pEnt;
acdbOpenAcDbEntity(pEnt, objId, AcDb::kForRead);
// Get the subentIds for the faces.
//
AcGePoint3d pickpnt;
AcGeMatrix3d xform;
int numIds;
AcDbFullSubentPath *subentIds;
pEnt->getSubentPathsAtGsMarker(AcDb::kFaceSubentType,
marker, pickpnt, xform, numIds, subentIds);
// Walk the subentIds list, highlighting each face subentity.
//
for (int i = 0;i < numIds; i++) {
pEnt->highlight(subentIds); // Highlight face.
// Pause to let the user see the effect.
//
acedGetString(0, 采用T("\npress <RETURN> to continue..."),
dummy);
pEnt->unhighlight(subentIds);
}
delete []subentIds;
pEnt->close();
}
void
highlightAll(const AcDbObjectId& objId)
{
TCHAR dummy;
AcDbEntity *pEnt;
acdbOpenAcDbEntity(pEnt, objId, AcDb::kForRead);
// Highlight the whole solid.
//
pEnt->highlight();
// Pause to let user see the effect.
//
acedGetString(0, 采用T("\npress <RETURN> to continue..."),
dummy);
pEnt->unhighlight();
pEnt->close();
}
Acad::ErrorStatus
addToModelSpace(AcDbObjectId &objId, AcDbEntity* pEntity)
{
AcDbBlockTable *pBlockTable;
AcDbBlockTableRecord *pSpaceRecord;
acdbHostApplicationServices()->workingDatabase()
->getSymbolTable(pBlockTable, AcDb::kForRead);
pBlockTable->getAt(ACDB采用MODEL采用SPACE, pSpaceRecord,
AcDb::kForWrite);
pSpaceRecord->appendAcDbEntity(objId, pEntity);
pBlockTable->close();
pEntity->close();
pSpaceRecord->close();
return Acad::eOk;
}
页:
[1]