Civil 3D 2023 Coding with Python Node Causes Constant Crashing

Does anyone else experience constant crashing when using a python node with civil 3d 2023? I find that if I just make a mistake with the naming convention of a list I’m trying to append integers to, my civil 3d instance will crash. It feels like almost any little mistake will not just throw an error but will actually cause an unhandled exception and crash my instance of civil 3d. I am unsure if this is a shared experience.

1 Like

Are you using try/ except in your code?

An unhandled exception would most likely happen on the execution side so it’s being thrown by C3D not Dynamo / python.

I’m not, perhaps I should be, but I’m not sure if that would stop the crashing. Yeah that seems to be the case. It seems like the autocad methods are what are throwing the unhandled exceptions. I’m just not sure why passing a variable that is named incorrectly into a method or something causes my whole instance to crash instead of just showing an error. It seems like the smallest things makes it crash. I was just wondering if other people are experiencing the same thing.

1 Like

From a .NET perspective it is really easy to end AutoCAD with a Fatal Error, which basically is a reaction to an Exception. That is why you should code inside a try-catch, to catch any exception and avoid a Fatal Error.

2 Likes

Yes, at least until you resolve the issues this could be an easy way to keep it from crashing.

Example of except with message here:

try:
except Exception() as ex:
    OUT ex.message
2 Likes

It’s the downside of not having a compiler or IntelliSense to catch things along the way. In general, if you’re writing code that is prone to throw an exception, put it in a try/catch block.

2 Likes

Thanks for the help everyone. I’m no longer crashing all the time which is a huge time saver :slight_smile:

1 Like