However it seems that all the breps given in the brepsToJoin argument must live for the full duration of the call - which is not a guarantee with the IEnumerable<Brep> type if that function isn’t taking ownership of the iterated Breps. I imagine that - if GC runs during this call it could clean up a Brep which this function isn’t keeping alive. I believe this is the case because I occasionally observe the following:
Repeat 2 times:
--------------------------------
at UnsafeNativeMethods.RHC_RhinoJoinBreps(IntPtr, IntPtr, Double)
--------------------------------
at Rhino.Geometry.Brep.JoinBreps(System.Collections.Generic.IEnumerable`1<Rhino.Geometry.Brep>, Double)
when I pass in “non-owned” Breps but it never happens when I pass in an owned collection. Does this sound right? Thanks!
The Breps you pass in need to stay alive for the duration of the call. A deferred LINQ query doesn’t hold onto the objects it has already yielded, so materialize it first:
Hey Dale, yes that’s definitely a solution from the calling side which is what I’ve done. Maybe if that should remain a requirement would it make more sense to change the JoinBreps signature to take in a List and have overloads for other owned data structures? It feels like a footgun as is. Or at least mentioning that in the documentation would be helpful. Thanks!