Define holes with AcDdSubDMesh::setSubDMesh() the same way as with AcGiGeometry::shell()

By Adam Nagy

I know how to set AcGiFaceData for AcGiGeometry::shell() to define holes. I’m trying to do the same with AcDbSubDMesh::setSubDMesh(), but that does not seem to work. Is it not possible to do that?

Solution

No it isn’t. You need to divide your manifold into faces without holes and set up the face data for AcDbSubDMesh::setSubDMesh() accordingly.

Another thing that might be helpful is using AcDb3dSolid entities, create the holes in them using boolean operations and then create an AcDbSubDMesh from that:

static void AcDbSubDMeshfromAcDb3dSolid(void)

{

  Acad::ErrorStatus err;

 

  ads_name name;

  ads_point pt;

  if (acedEntSel(L"Select a solid", name, pt) != RTNORM)

    return;

 

  AcDbObjectId id;

  acdbGetObjectId(id, name);

  AcDbObjectPointer<AcDb3dSolid> ptrSolid(id, AcDb::kForRead);

 

  AcDbFaceterSettings settings;

  AcGePoint3dArray pts;

  AcArray faces;

  AcGiFaceData* faceData;

  err = acdbGetObjectMesh(ptrSolid, &settings, pts, faces, faceData);

  if (faceData)

  {

    delete [] faceData->trueColors();

    delete [] faceData->materials();

    delete faceData;

  }

 

  AcDbObjectPointer<AcDbSubDMesh> ptrMesh;

  ptrMesh.create();

  ptrMesh->setSubDMesh(pts, faces, 0);

 

  AcDbDatabase* pDb =

    acdbHostApplicationServices()->workingDatabase();

  AcDbBlockTableRecordPointer

    ptrMS(ACDB_MODEL_SPACE, pDb, AcDb::kForWrite);

  ptrMS->appendAcDbEntity(ptrMesh);

}

 


Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading