How to force an insert to be refreshed?

By Gopinath Taget

Lets say you are looking for a way to force an update of the AcDbBlockReferences after modifying its AcDbBlockTableRecord without having to call REGEN?

The simplest and fastest way to do this is to iterate the current space, open all the AcDbBlockReference entities for write and call the assertWriteEnabled() method. Because your block definition could be nested in another block definition, you should call assertWriteEnabled() on all AcDbBlockReferences that are present.

As an alternative method (which may decrease the time spent on the process) and to avoid unnecessary ‘Undo’ information recording, you can temporarily turn off the Undo recording and restore it after the process. To do this, use the ‘AcDbDatabase::disableUndoRecording()’ method.


Comments

One response to “How to force an insert to be refreshed?”

  1. Tony Tanzillo Avatar
    Tony Tanzillo

    “The simplest and fastest way to do this is to iterate the current space, open all the AcDbBlockReference entities for write and call the assertWriteEnabled() method.”
    I’m not sure that’s the ‘fastest’ way. :d
    You can open the AcDbBlockTableRecord for the block whose insertions you want to refresh, and call getBlockReferenceIds( false, true ) to get an array of the ids of all insertions of the block, and all insertions of all dependent blocks, then open each of them for write and call assertWriteEnabled().
    You should also call acdbForceOpenObjectOnLockedLayer() before opening each insertion if it’s on a locked layer.

Leave a Reply to Tony TanzilloCancel reply

Discover more from Autodesk Developer Blog

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

Continue reading