Deleting Complex Entities

If an application deletes a complex entity that is not database resident, the application is responsible for also deleting all the subentities associated with that complex entity.

Complex entities and their subentities are listed in the Entities Defined section. Complex entities that are not database resident do not include an AcDbSequenceEnd object.

The following example shows how to delete the subentities of an AcDb2dPolyline:

void delete2dPoly(AcDb2dPolyline* pPline)
{ 
  AcDbObjectIterator* pIter=pPline->vertexIterator();
  AcDbEntity* pEnt; 
  for (; !pIter->done(); )
  {
    pEnt=pIter->entity(); 
    // Must step the iterator first so that it is no longer 
    // sitting on the entity that's about to be deleted.
    pIter->step();
    delete pEnt;
  }
  
  delete pIter;
  delete pPline;
}