"TypeError" When Trying to Get Block Table Record of Model Space

Thanks Zachri, I knew you’d come help!

That worked great thanks! I’ll be sure to reference this going forward. But now I’m trying to iterate over the block table record. I remember previously you stated that the block table record:

When I do this:

with adoc.LockDocument():
    with adoc.Database as db:
        with db.TransactionManager.StartTransaction() as t:
            bt = t.GetObject(db.BlockTableId, OpenMode.ForWrite)
            btr = bt.get_Item(BlockTableRecord.ModelSpace)
            
            objectIDs = []
            for oid in btr:
                oid.append(objectID)

            t.Commit()
            pass

I get the exact same TypeError as previously mentioned. But this method worked fine in the last python script I wrote that replaced blocks across sheets. It’s really confusing! I was also able to iterate through the “Block Table” as if it was a list in the last script without issue. I’m not sure what has changed here except that I’m already in an active dwg.

Also, I seem to find the following code:

btr = t.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite)

throughout the forum. Did this work previously but doesn’t now for some reason?