Am I completely missing something that is staring me straight in the face?
The problem and you might have to regen to get it show both, but this will update the block's clone and original block.
The code is a basic example and it is like the ObjectIds are not being translated correctly.
I have even broke it up into 2 commands to do the changing of the Clone Entities to see if the translating was done after the transaction commited but they still both change.
This should deepclone a BlockTableRecord and name it 'OriginalName' + 'COPY' then change all the entities in the new BlockTableRecord to red but also changes the original?
It is like the entities in the newly cloned BlockTableRecord and the original BlockTableRecord are pointing to same object, and the ids were not translated.
public void WTF()
using (Transaction trx = db.TransactionManager.StartTransaction())
PromptEntityOptions peo = new PromptEntityOptions("\nSelect Block Reference: ");
peo.SetRejectMessage("\n That was not a Block Reference");
PromptEntityResult per = ed.GetEntity(peo);
if (per.Status != PromptStatus.OK)
BlockReference bref = (BlockReference)trx.GetObject(per.ObjectId, OpenMode.ForRead);
BlockTableRecord btr = (BlockTableRecord)trx.GetObject(bref.BlockTableRecord, OpenMode.ForRead);
string btrName = btr.Name "COPY";
BlockTable bt = (BlockTable)trx.GetObject(db.BlockTableId, OpenMode.ForRead);
BlockTableRecord newBtr = null;
newBtr = (BlockTableRecord)trx.GetObject(bt[btrName], OpenMode.ForRead);
//IdMapping idMap = new IdMapping();
//newBtr = (BlockTableRecord)btr.DeepClone(bt, idMap, false);
newBtr = (BlockTableRecord)btr.DeepClone(bt, new IdMapping(), true);
newBtr.Name = btrName;
foreach (ObjectId id in newBtr)
Entity ent = trx.GetObject(id, OpenMode.ForRead) as Entity;
if (ent == null)
ent.ColorIndex = 1;
bref.BlockTableRecord = newBtr.ObjectId;