I have an issue with python code I wrote and cannot figure out what to do to fix it. I am trying to split a large number of intersecting meshes between each other. All the meshes are initially made conformal and contain triangular faces only, so the Split command should work fine. The problem I found is that when I use Mesh.Split method (rhinocommon), Rhino 7 consumes large amount of memory and does not release it at all. Every time I run the script on about 70 meshes containing in total ~160K faces, Rhino 7 consumes ~1Gb of memory. This does not happen in Rhino 6, but Mesh.Split method does not produce adequate results either (I believe there were changes done to mesh intersection/split algorithms for Rhino 7). Below is a part of my python script.
def SplitMeshes(): go = Rhino.Input.Custom.GetObject() iniMeshes = list() newMeshes = list() for objRef in go.Objects(): rObj = objRef.Object() if rObj.IsNormal and rObj.ObjectType == Rhino.DocObjects.ObjectType.Mesh: iniMeshes.append(rObj.DuplicateGeometry()) for i,ma in enumerate(iniMeshes): print 'Working on mesh: ', i+1 splitMeshes = ma.Split(iniMeshes) if len(splitMeshes) > 1: newMeshes.append(splitMeshes) rs.DeleteObject(go.Object(i).ObjectId) for ma in iniMeshes: ma.Dispose() del iniMeshes[:]
Or maybe I don’t clear/dispose some containers or objects properly?