Civil3D API Python3 syntax error

Hi,
any ideas what Python3 syntax error have I here?
It gives only a warning here, but if I put it in a function C3D crashes.
python3 crash

Semicolon on line 39.

It is a known issue of Python.Net that does not support the correct conversion of IDisposable objects (those that you use in context managers, the ‘with’ keyword in Python).
fyi @Michael_Kirschner2 this effectively prevents from using Python 3 in Dynamo for Civil 3D

1 Like

Sadly that wasn’t that :confused:
I guess there is something with the StyleCollection Item syntax, but no idea what.
python3 crash

Oh, okay. So for now IronPython2 it is. Thanks.

Try this instead of using the indexer:
bs = civdoc.Styles.ProfileViewBandSetStyles.get_Item(“Cut and Fill”)

2 Likes

Oh wow that works. Thanks.

1 Like

the issue is that the error message you got and the actual problem were different and annoyingly you need to change the syntax as if in Python 3 the collection[index] were not supported (which is not the case of course)

2 Likes

This is generally a big problem for me lately with python nodes as I’m not a programmer only an engineer, so usually I only have trial and error from line to line and then, I still don’t know what’s wrong. … But one step at a time, thanks for the info.