Is there a a proper way to iterate through mesh faces when using Rhinocommon to prevent crashing and perhaps memory issues? i am using Mesh.TopologyEdges and Collections.MeshTopologyEdgeList functions in an attempt to checkerboard a mesh by appending True or False to a list that correlates to each face.
i find my script does work on smaller meshes (both quads and triangles), and works very fast! but i find with larger meshes (1000+ faces) it just crashes rhino entirely. also, if i load the script immediately when rhino opens on a 1000 face mesh, it will create the list the first time. if i run it a second time, it will crash. this makes me think there is either a memory issue or im not dealing with mesh data properly.
I appreciate any thoughts on the subject!
Any sample code and model you can provide could help us track down the issue…
Here is a simple version of what i am trying to achieve. bear in mind im sort of new to using Rhinocommon so im sure my usage is probably not as methodical as it should be.
checkerboard_sample.3dm (238.1 KB) checkerboard_sample.py (1.4 KB)
in the hopes of somehow being able to narrow down the issue, i’ve added a terminating condition based on generation of the recursive element. it does seem to work fine on the large mesh when i set it to under 1000. sometimes it works at 1000, sometimes it fails. and any number greater it usually crashes. there does seem to be some inconsistency, since it will sometimes run at 1000 generation limit, but sometimes will fail.
hopefully this at least rules out the possibility of infinite recursion
checkerboard_sample_termination.py (1.5 KB)
upon further research, i’ve come to a decision that this method of recursion may not be the best option for this, at least for using python maybe. I think i will try an implementation that is based more on loops than recursion.