Is it possible to create a BRep object out of a surface using ARX?
Solution
The following code illustrates how to achieve that. Once the BRep object has been created, you could use it to access the NURB information of your surface for example:
void BrepSurface(AcDbSurface* pSurface)
{
AcDbBody* pBody = new AcDbBody();
Acad::ErrorStatus es = pBody->setASMBody(pSurface->ASMBodyCopy());
AcBrBrep* pBrep = new AcBrBrep();
if(AcBr::eOk == pBrep->set(*pBody))
{
AcBrBrepFaceTraverser* pFaceTrav = new AcBrBrepFaceTraverser;
if(AcBr::eOk == pFaceTrav->setBrep(*pBrep))
{
for(pFaceTrav->restart();!pFaceTrav->done();pFaceTrav->next())
{
AcBrFace face;
if(AcBr::eOk == pFaceTrav->getFace(face))
{
double area = 0.0f;
face.getSurfaceArea(area);
acutPrintf(L"\nSurface Area: %f", area);
AcGeNurbSurface nurbSurface;
face.getSurfaceAsNurb(nurbSurface);
//face.getSurfaceAsTrimmedNurbs();
}
}
}
delete pFaceTrav;
}
delete pBrep;
}
void BrepSurface()
{
ads_name eName;
ads_point pt;
if(RTNORM != acedEntSel(L"\nSelect a surface: ", eName, pt ))
return;
AcDbObjectId id;
acdbGetObjectId(id, eName);
AcDbSurface* pSurface = NULL;
acdbOpenObject(pSurface, id, AcDb::kForRead);
if(pSurface == NULL )
{
acutPrintf(L"\nNot a surface…");
return;
}
BrepSurface(pSurface);
pSurface->close();
}

Leave a Reply to EvangelosCancel reply