I have a script that works on individual planar curves and creates hundreds of offset curves with Rhino.Geometry. This is done in an ghpython component, that imports custom python classes. Results are great.
On one curve the script has an acceptable runtime of approx. 10-12 s depending on the inputs.
However this has to be applied to 100 - 200 curves, thus I would like to batch run it for 1 hour and be done with it.
Unfortunately the execution time increases from 10s on the first run, to 20s on the 2nd and so forth. So I can only process really small batches in an acceptable time frame. If I loop over too many curves Rhino becomes unresponsive and the risk of crashing is increased.
It does not matter whether:
- I feed the curves as a list access / array and loop over the curves within the python component
- I design the component for a single curve and then use implicit looping via “item access” and feed the curves as array.
Runtime/behaviour is almost identical.
I looked for bottlenecks or growing arrays in the code, but just the smallest operations take longer and longer on each subsequent run. e.g. 50 ms to 100 ms to 150 ms.
The heavy lifting is done in Rhino.Geometry with Offsets of NurbsCurves, PolyCurves, Trimming and Joining results etc.
Is there any way to reset and free rhino python ressources within the loop to avoid this behaviour?
The topic has been brought up here, but that is from 2014 and I am not sure that is still an issue:
https://www.grasshopper3d.com/m/discussion?id=2985220%3ATopic%3A997897
BR Conrad
3 posts - 2 participants