BrepBrep intersection not threadsafe in Rhino 5 64bit?

Using the Grasshopper python component I wrote a code that intersects lots of breps with each other.
To make it faster I used parallel processing wich worked fine under Rhino 5 32bit, on a 64bit Rhino the component crashes my whole Rhino instantly.

The function used was Rhino.Geometry.Intersect.Intersection.BrepBrep()

Is this function not threadsafe?


many of the Rhino Common methods are not threadsave and will crash rhino but in your case it may depend on the implementation of the treading module used or the way you append results of the intersection. Without a code example it is hard to track down errors in your code.

Below example using System.Threading and Rhino.Geometry.Intersect.Intersection.BrepBrep() seems to work without crashing Rhino x64:

import Rhino
import scriptcontext
import rhinoscriptsyntax as rs
import System
import System.Threading.Tasks as tasks
import itertools 

def DoSomething():
    ids = rs.GetObjects("Select breps", 8+16, True, False)
    if not ids: return 
    breps = [rs.coercebrep(id, True) for id in ids]
    pairs = list(itertools.combinations(breps, 2))
    curves = [None] * len(pairs)
    tolerance = scriptcontext.doc.ModelAbsoluteTolerance
    intersector = Rhino.Geometry.Intersect.Intersection
    def MyWorker(w): 
        rc, c, p = intersector.BrepBrep(pairs[w][0], pairs[w][1], tolerance)
        if rc: curves[w] = c
    tasks.Parallel.ForEach(xrange(len(pairs)), MyWorker)
    flatten = list(itertools.chain(*curves))
    crv_ids = [scriptcontext.doc.Objects.AddCurve(c) for c in flatten]

I´ve tried it using this geometry example: ExampleGeometry.3dm (340.0 KB)


Thanks a lot for your detailed answer. As I am fairly new to coding in general there are some things going on in your code I am not familiar with. I used the wich also did all the appending for me.

I will look into your code and see if I can make use of system.threading instead.

Thanks again

By the way… I got an error message when I accidently ran the old code again.
Something like Runtime Error: Vital function call. Unfortunately the expected crash happened a second later so I couldnt take a screenshot.

Any Idea on what that could mean?


if this was repeatable crash, please post the surface geometry and script where the error occured.


Here is the .gh file. “Works” (Works not =D ) with an empty rhino scene. The results don’t vary with changed geometry.
Rhino crashes as soon as I connect the parallel version of the python component but as mentioned it didn’t under 32Bit so I am pretty confused about what the problem is. (7.6 KB)

Thanks again!

Hi Henning,

my script posted above is not a grasshopper / python ready code but usable from within rhino to show that Rhino.Geometry.Intersect.Intersection.BrepBrep() is threadsave. Please try this:

  • close GH
  • open the example geometry posted above
  • open the Python script editor using _EditPythonScript
  • paste my script example from above in the code area of the Python editor
  • run the script, when it asks for the breps, select all spheres, then _Enter

Do you get a crash ?

I´ve opened your gh file but it does not contain the code posted above in the python component. To get this work in a GH python component, do this:

  • double click the canvas in GH and add new empty Python script component.
  • right click on the x input and set it to List Access
  • paste this code into the component:

the gh definition then looks like this:

Below is the gh file, but it was created using Rhino 6 Wip. If you cannot open it, try the steps above to create your own. (8.8 KB)

Any better ?


Works perfectly fine! Now the question is: why does my code produce a crash and how can I avoid that?

Thanks yet again

Just go through it line by line. Comment out everything first, then start from the top to see where the crash occurs. I cannot say anything about ghpythonlib.parallel as i never used it.


Already tried that but with no success as long as I have nu clue on why this works in 32Bit but not in 64 I am pretty much helpless. You dont happen to know whom I could ask about that matter do you?

@DavidRutten can you please take a look in the component posted by @SmallChief above ?


Sorry, Python is not my strong suit. @piac and @stevebaer are the experts here.

Sorry guys, but I’m not going to be able to help with this in the near future (at least the next few days).

Hi @SmallChief

I tested your definition in both Rhino 5SR12 from August of last year and in Rhino WIP and there was no crash even after connecting the second scripting component (I assume the crash was in there?). Is there something else I need to do to reproduce?



Giulio Piacentino
for Robert McNeel & Associates

Hi @piac,
first I want to thank you for taking the time to help me.

I just tested again and keep getting the same problem. Instant crash after connecting the second script.

I am running win 7, with Rhino Version 5 SR12 64-bit (5.12.50810.13095, 10.08.2015).
You probably havn’t got any leads on what else might cause this? Would a crash dump file help to solve this problem?


Let me try with exactly your version.


I tested with the same version and it appears to work well in the same way. Could you save a screenshot of:

  • the dialog that appears after running _AboutRhino?
  • the Grasshopper version that is shown in the lower right corner of the Grasshopper window?
  • the GhPython version that appears in the lower right corner of the GhPython script editor?

You can either post them here or email them to me.


Giulio Piacentino
for Robert McNeel & Associates

I just created a parallel processing Python script to do Boolean unions that works fine, here:

Thanks a lot, but I’m not doing any boolean unions in my Script. :wink:

Could it be the .NET version perhaps?