[每日一码] 设置3DSOLID实体每个面的颜色
void TestBrep(void){
Adesk::Int32 len;
ads采用namessname0;
struct resbuf *buffer;
buffer = acutBuildList(-4, 采用T("<AND"),
RTDXF0, 采用T("3DSOLID"),
-4, 采用T("AND>"), RTNONE);
acutPrintf(采用T("\nSelect a box:"));
acedSSGet(NULL, NULL, NULL, buffer, ssname0);
acutRelRb(buffer);
if (RTNORM == acedSSLength(ssname0, &len))
{
ads采用nameent;
AcDbObjectId entId;
for(long k = 0; k < len; k++)
{
acedSSName(ssname0, k, ent);
acdbGetObjectId(entId, ent);
settingDifferentColorToEachFace(entId);
}
acedSSFree(ssname0);
}
}
void settingDifferentColorToEachFace(AcDbObjectId solidId)
{
AcCmColor specialColor;
AcDb3dSolid* pSolid;
if (Acad::eOk == acdbOpenObject(pSolid, solidId, AcDb::kForRead))
{
AcDbFullSubentPath path(solidId, AcDbSubentId());
AcBrBrep brep;
AcBr::ErrorStatus bs = brep.setSubentPath(path);
if (bs != AcBr::eOk)
return;
//Initialize the BrepFace traverser
AcBrBrepFaceTraverser bft;
bs = bft.setBrep(brep);
if (bs != AcBr::eOk)
return;
AcArray<AcDbSubentId> arrSubentId;
// Traverse all faces
for (;!bft.done();bft.next())
{
AcBrFace face;
bs = bft.getFace(face);
if (bs != Acad::eOk)
{
acutPrintf(L"\ngetFace failed");
页:
[1]