# Access to modelSpace by .py script

**URL:** <https://forum.dynamobim.com/t/access-to-modelspace-by-py-script/107639>\
**Category:** Civil 3D\
**Tags:** python\
**Created:** [January 30, 2025, 1:03pm UTC](https://forum.dynamobim.com/t/access-to-modelspace-by-py-script/107639 "2025-01-30T13:03:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![artur.leszczynski](https://avatars.discourse-cdn.com/v4/letter/a/df788c/32.png) [@artur.leszczynski](https://forum.dynamobim.com/u/artur.leszczynski)\
**Post date:** [January 30, 2025, 1:03pm UTC](https://forum.dynamobim.com/t/access-to-modelspace-by-py-script/107639/1 "2025-01-30T13:03:26Z")

</div>

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: ")
> 
> ```

---

<div class="post-metadata">

**Author:** ![Mike.Buttery](https://avatars.discourse-cdn.com/v4/letter/m/b19c9b/32.png) [@Mike.Buttery](https://forum.dynamobim.com/u/Mike.Buttery)\
**Post date:** [January 31, 2025, 3:25am UTC](https://forum.dynamobim.com/t/access-to-modelspace-by-py-script/107639/2 "2025-01-31T03:25:18Z")

</div>

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