Close

Relief for ODA Team in Ukraine

Learn more
ODA Drawings SDK
Overview of Exploding Entities

The explode operation produces a set of simple entities from a complex entity.

There are four functions related to exploding entities. The first two are:

  • explode() — Produces an array of pointers to non-database resident entities. No changes are made in the database.
  • explodeToBlock() — Creates a set of database-resident entities that are placed into a specified Block Table Record.

The explode() and explodeToBlock() functions may not be able to explode some complex entities, for example, MInsert entities and block references where the Block Table Record has “explode allowed” set to false.

The remaining two functions related to exploding entities are:

  • explodeGeometry() — Function similar to explode(), but explodes any complex entity and produces a visual result that is as close to the original entity as possible.
  • explodeGeometryToBlock() — Function similar to explodeToBlock(), but explodes any complex entity and produces a visual result that is as close to the original entity as possible.

The following example demonstrates how to explode all external references from model space using the explodeToBlock() method:


void explode_external_to_block(OdEdCommandContext* pCmdCtx)
{
  OdDbDatabasePtr pDb = pCmdCtx->baseDatabase();

  OdDbBlockTableRecordPtr pBTR = OdDbBlockTableRecord::cast(
                                   pDb->getModelSpaceId().safeOpenObject(OdDb::kForWrite));
  OdDbObjectIteratorPtr pIt = pBTR->newIterator();
  OdDbObjectIdArray ent2exp;
  while (!pIt->done())
  {
    OdDbEntityPtr entity = pIt->objectId().safeOpenObject(OdDb::kForWrite);
    if (entity->isKindOf(OdDbBlockReference::desc())) 
    {
      OdDbBlockReferencePtr blockRef = entity;
      OdDbBlockTableRecordPtr block = blockRef->blockTableRecord()
                                        .safeOpenObject(OdDb::kForWrite);
      if (block->isFromExternalReference())
        OdDbXRefMan::bind(block);
      blockRef->explodeToBlock(pBTR);
      blockRef->erase();
    }
    pIt->step();
  }
}

See Also

Exploding Entities

Working with External References

Copyright © 2002 – 2022. Open Design Alliance. All rights reserved.