Access to modelSpace by .py script

Hi, I have problem with accessing ModelSpace by python script. I get BlockTable object from database transaction but both bt[BlockTableRecord.ModelSpace] and db.CurrentSpaceId don’t return any result’s. Script uses CPython3.

with adoc.LockDocument():
with adoc.Database as db:
with db.TransactionManager.StartTransaction() as t:

        print("btr")
        #Polilinie
        polilinie = []
        try:
            bt = t.GetObject(db.BlockTableId,OpenMode.ForRead)
            print(bt)
            btr = t.GetObject(db.CurrentSpaceId,OpenMode.ForRead)
            print(btr)
            for x in btr:
                print(x.ObjectClass.DxfName)
                if x.ObjectClass.DxfName == "LWPOLYLINE":
                    poliO = t.GetObject(x,OpenMode.ForRead)
                    polilinie.append(poliO)
            
            print(f"\n{polilinie}")
        
        except:
            print(f"nie udało się otworzyć dokumentu: ")

Hi Artur, welcome :wave:
You could try SymbolUtilityServices.GetBlockModelSpaceId(db) to get the model space id