# How to get Layer property in Python script

**URL:** <https://forum.dynamobim.com/t/how-to-get-layer-property-in-python-script/91060>\
**Category:** Civil 3D\
**Tags:** python, dynamo\
**Created:** [June 23, 2023, 7:15am UTC](https://forum.dynamobim.com/t/how-to-get-layer-property-in-python-script/91060 "2023-06-23T07:15:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![geert.drijfhout](https://avatars.discourse-cdn.com/v4/letter/g/a4c791/32.png) [@geert.drijfhout](https://forum.dynamobim.com/u/geert.drijfhout)\
**Post date:** [June 23, 2023, 7:15am UTC](https://forum.dynamobim.com/t/how-to-get-layer-property-in-python-script/91060/1 "2023-06-23T07:15:45Z")

</div>

Hi guys, I’ve been struggling a bit on how to get my layer and would like to share what I just found out:

`t.GetObject(acLyrTbl[slayername], OpenMode.ForRead)` worked fine in IronPython but just doesn’t do anything in CPython. However the documentation (.NET) has not changed so I guess it is a syntax issue. Then I came across this post: ["TypeError" When Trying to Get Block Table Record of Model Space - #6 by WrightEngineering](https://forum.dynamobim.com/t/typeerror-when-trying-to-get-block-table-record-of-model-space/77729/6)

Apparently this method goes for other db.tables as well:

```auto
acLyrTblRecId = acLyrTbl.get_Item(sLayername)
acLyrTblRec = t.GetObject(acLyrTblRecId, OpenMode.ForRead)

```

It costed me quite a while to get it so to help you avoid futere problems …

_PS: also I would like to complain about the feedback in CPython → really downgrade from IronPython, it would help greatly if this part was improved in the future. I see more topics with solutions saying just use IronPython_

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [June 23, 2023, 9:52am UTC](https://forum.dynamobim.com/t/how-to-get-layer-property-in-python-script/91060/2 "2023-06-23T09:52:04Z")

</div>

> [@geert.drijfhout](#):
>
> PS: also I would like to complain about the feedback in CPython → really downgrade from IronPython, it would help greatly if this part was improved in the future. I see more topics with solutions saying just use IronPython

Sadly the Dynamo team doesn’t own CPython, so there is very little we can do to resolve such issues. Remember that the IronPython 2 was deprecated as it is no longer supported by the Python authors and as such is a security risk; the Dynamo team would have kept with it if that was an option. There is an IronPython 3 package which has been released; however that isn’t always a slam dunk either as Python 3 also has some changes compared to Python 2. In the end the community will get all the required syntax and issue resolutions out there, but for now you may want to look into the IronPython 3 package to see if that is easier for your active work.

---

<div class="post-metadata">

**Author:** ![geert.drijfhout](https://avatars.discourse-cdn.com/v4/letter/g/a4c791/32.png) [@geert.drijfhout](https://forum.dynamobim.com/u/geert.drijfhout)\
**Post date:** [June 23, 2023, 10:03am UTC](https://forum.dynamobim.com/t/how-to-get-layer-property-in-python-script/91060/3 "2023-06-23T10:03:18Z")

</div>

Thank you Jacob, I know you guys thrive to support us in every possible way. Therefore thank you for the suggestions. At the moment I tend to develop some parts in 2020 on IP2, will give IP3 a chance soon.

I had at least found my way around with the topics on this forum! 💪

---

<div class="post-metadata">

**Author:** ![mzjensen](https://avatars.discourse-cdn.com/v4/letter/m/b77776/32.png) [@mzjensen](https://forum.dynamobim.com/u/mzjensen)\
**Post date:** [June 23, 2023, 2:43pm UTC](https://forum.dynamobim.com/t/how-to-get-layer-property-in-python-script/91060/4 "2023-06-23T14:43:11Z")

</div>

> [@geert.drijfhout](#):
>
> Apparently this method goes for other db.tables as well:

Just wanted to add to this. This actually applies broadly anytime you access an item in a collection using an indexer (i.e., square brackets []). It’s simply one of the quirks of Python.NET, and using `.get_Item()` is the best known workaround at this point.
