# Multithread Boolean Difference - GHPhython with Trees retained

**URL:** <https://discourse.mcneel.com/t/multithread-boolean-difference-ghphython-with-trees-retained/84735>\
**Category:** Grasshopper\
**Created:** [June 14, 2019, 7:00am UTC](https://discourse.mcneel.com/t/multithread-boolean-difference-ghphython-with-trees-retained/84735 "2019-06-14T07:00:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kiteboardshaper](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/kiteboardshaper/32/767533_2.png) [@kiteboardshaper](https://discourse.mcneel.com/u/kiteboardshaper)\
**Post date:** [June 14, 2019, 7:00am UTC](https://discourse.mcneel.com/t/multithread-boolean-difference-ghphython-with-trees-retained/84735/1 "2019-06-14T07:00:15Z")

</div>

Hi All,

I had a recent project that required a lot of Boolean Differences in Grasshopper - all on separate branches on a data tree.

The standard SDiff component even a small sub-set of the final project was giving a run time of ‘life of the universe’.

To speed things up I went looking for multithread examples of Sdiff and found:

BWA C# example:

> **[Multi-Boolean — BWA](https://www.washburnarchitecture.com/blog/2018/6/5/multi-boolean)**
>
> Making quick work of custom perforating hundreds of panels by multi-threading boolean difference operations in Grasshopper.

Which then also lead me to djordje’s GHpython example:

> **[GhPython BooleanDifference Multi threading](https://www.grasshopper3d.com/forum/topics/ghpython-booleandifference-multi-threading)**
>
> Hi there,
> 
> I'm trying to make a multi threading ghpython component to run in paralel a command for booleand difference.
> I have a series of bpreps that each nee…

For some reason I could not get the C# version to work, but the Python one worked well in my project EXCEPT - it was dumping the Tree Structure of my input data and returning a flatten list.

I quick bit of research into GHpython and the Tree libraries and I was able to mod the code to carry the tree structure into the output data.

 ![Image%2020190614001](https://global.discourse-cdn.com/mcneel/uploads/default/original/3X/f/1/f1c6e069bfbdb7b1fba9ecc8aad7628bc16fde8b.png) [190614\_Mutlithread SDiff examples.gh (469.7 KB)](https://discourse.mcneel.com/uploads/short-url/o3kIQKkQcH5CmP253UWUKj8BuCz.gh)

---

<div class="post-metadata">

**Author:** ![kiteboardshaper](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/kiteboardshaper/32/767533_2.png) [@kiteboardshaper](https://discourse.mcneel.com/u/kiteboardshaper)\
**Post date:** [June 14, 2019, 7:18am UTC](https://discourse.mcneel.com/t/multithread-boolean-difference-ghphython-with-trees-retained/84735/2 "2019-06-14T07:18:28Z")

</div>

Now - is is possible to do the same with the MESHPOLYLINE from RhinoCommon?

---

<div class="post-metadata">

**Author:** ![BEMAD](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/bemad/32/653825_2.png) [@BEMAD](https://discourse.mcneel.com/u/BEMAD)\
**Post date:** [June 14, 2019, 8:53am UTC](https://discourse.mcneel.com/t/multithread-boolean-difference-ghphython-with-trees-retained/84735/3 "2019-06-14T08:53:37Z")

</div>

Hi @kiteboardshaper, i’ve got any knowledge in programming but see that it could mainly speed up a Huge file i often use.  
Would you be able to make or modify those tool for Solid intersection of one Breps (or multiple X Breps) with severals graft Y ones which would give a (tree of Y branch of X item) ??? Would be amazing!!

---

<div class="post-metadata">

**Author:** ![gustojunk](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/gustojunk/32/771862_2.png) [@gustojunk](https://discourse.mcneel.com/u/gustojunk)\
**Post date:** [June 14, 2019, 9:00am UTC](https://discourse.mcneel.com/t/multithread-boolean-difference-ghphython-with-trees-retained/84735/4 "2019-06-14T09:00:52Z")

</div>

Nice! I’ll definitely take a look at this soon.

Are we getting multi-threaded booleans in GH2? It would be extremely helpful for us.

G

---

<div class="post-metadata">

**Author:** ![kiteboardshaper](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/kiteboardshaper/32/767533_2.png) [@kiteboardshaper](https://discourse.mcneel.com/u/kiteboardshaper)\
**Post date:** [June 14, 2019, 9:40am UTC](https://discourse.mcneel.com/t/multithread-boolean-difference-ghphython-with-trees-retained/84735/5 "2019-06-14T09:40:19Z")

</div>

From what I understand Boolean operations are by there nature single threaded.

In this situation I have different objects on matched branches in data trees that need to be Boolean-ed - this type of work flow CAN be sent out to different threads for a decent increase in processing speed over the standard GH component.

If you are dealing with a single object there isn’t much that can be done to speed things up.

Cheers

DK
