Message 1 of 7
Delete a block with attributes

Not applicable
12-08-2004
09:06 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I want to delete a block containing attributes, the following couple of
lines (minus all the stardard peripheral code) will delete the block...
if ((blkRef = AcDbBlockReference::cast(pEnt)) != NULL)
{ pBlkTableRec->getBlockReferenceIds(refEnts);
blkRef->erase();
blkRef->close();
}
You might ask why Im getting the RefID, because I want to purge the
block after erasing so I can reinsert the block from an external file.
After the above code executes, the block indeed disappears from the
screen, but my code to purge does not seem to work, heres how I did that...
AcDbDatabase* pDb = acdbHostApplicationServices()->workingDatabase();
pDb->purge(refEnts);
after this, the block def remains so my subsequent insert is not as
expected.
Am I correct in assuming that deleting the block did NOT delete its
attributes? are there now "orphan" attribute defs with no block?
If this is the case, then before deleting the blockref, do I need to
iterate through its attributes and delete them first?
Lastly, is there an easier way of doing this??? :)
Thanks
Perry