Dynamo Crash: Surfaces generated and intersected by a loop

Hello everyone,

I’m programming some nodes using python scritps, but I have a terrible crash everytime I test my nodes in big models. The goal of the code is to intersect a big surface, using a matrix of small surfaces. In the pictures you can watch the procedure. I think that the code is correct because sometimes it generate every surface correctly, but sometimes it doesn’t. When I use less horizontal divisions, and less vertical divisions (stories of a building), Dynamo works perfect, but when I increase the number of those divions, Dynamo crashes repently. And also when you change the number of divisions from a small number (e.g. 3) to a bigger number (e.g. 30) also crashes. I show part of the code, it’s pretty basic, do you think there is a better way to do it?

Have you ever experienced something like this? I don´t know if the computer, the code, the python platform or dynamo is causing this problem.






Thank you for your help!

when you use Dynamo geometry functions in python it is the same as using them from c# - you’ll have to dispose of intermediate geometry.

It’s a tough problem. Please see this: https://github.com/DynamoDS/Dynamo/wiki/Zero-Touch-Plugin-Development#dispose--using-statement

basically - if you don’t return the geometry from the python node, or it didnt come from another node as input, you must call dispose on it.

This should be done for surfaces, solids, and curves - it’s probably okay to skip vectors, points, etc.

@Michael_Kirschner just a query, when the import statement is used in Python is it not the equivalent of the using statement within C#? What I’m getting at is, is object disposal not handled by method 1 (of the link) and using the Dispose() method in this case is consequently a redundant action?

1 Like

Hi @Thomas_Mahon you are confusing a using directive and using statement in c# - these are totally, 100% different from each other.

https://msdn.microsoft.com/en-us/library/yab9swk4.aspx

https://msdn.microsoft.com/en-us/library/yh598w02.aspx

Thanks for the info. If I understand correctly then, the ‘directive’ using statement does garbage collection not the statement…and python has no equivalent. Cheers!

I should have been more clear - the using directive is analogous to the python import statement :wink: it just references a namespace / assembly

the using statement with {}

calls dispose before the block exits - neither do garbage collection… dispose is unused for unmanaged code (native code like c++) that doesnt know anything about .net garbage collection and thus must be cleaned up manually with dispose or using.

there is no using in Python but you can use with that cleans up after itself:

Cheers!

1 Like

Hello,

The solution proposed by @Michael_Kirschner works perfectly! I didn’t know that python nodes need to dispose higher dimension geometries as surfaces and solids.

I used the method Dispose() in those geometries, and in some cases I used “del” method, in the cases of lists. And also I used the destructor del within some object classes.
The solution by @Konrad_K_Sobon its nice too, I used in one function. I recommend to read the link that he shared. It’s important to maintain the code clean to dispose the objects correctly and avoid the strange behavior of dynamo.


Doing this, it came to my mind another doubt… I hope you can help me:

I’m programming some nodes in python to create a package and publish it… But I read that you can code in C#, using something called Zero Touch and even you can custom your own nodes, like create combobox nodes… My question is: is it better/more efficient to create nodes using C#? Is it difficult to translate the python code to C#? (I don’t know nothing about C#)

Thank you for your answers!

That’s a subject that needs a new thread. Thanks!

1 Like