GhPython BooleanDifference Multi threading - Grasshopper2024-03-28T20:46:22Zhttps://www.grasshopper3d.com/forum/topics/ghpython-booleandifference-multi-threading?feed=yes&xn_auth=noIn that case you are doing it…tag:www.grasshopper3d.com,2014-01-23:2985220:Comment:9957532014-01-23T21:49:09.132Zdjordjehttps://www.grasshopper3d.com/profile/djordje
<p>In that case you are doing it pretty well.<br/>By the way, I made a mistake. The line:</p>
<blockquote><p>newTree.AddRange(diff, _paths)</p>
</blockquote>
<p>should be:</p>
<blockquote><p>newTree.AddRange(diff, path)</p>
</blockquote>
<p></p>
<p>Or you could just delete the line:</p>
<blockquote><p>path = ghp.GH_Path(_paths)</p>
</blockquote>
<p></p>
<p></p>
<p>In that case you are doing it pretty well.<br/>By the way, I made a mistake. The line:</p>
<blockquote><p>newTree.AddRange(diff, _paths)</p>
</blockquote>
<p>should be:</p>
<blockquote><p>newTree.AddRange(diff, path)</p>
</blockquote>
<p></p>
<p>Or you could just delete the line:</p>
<blockquote><p>path = ghp.GH_Path(_paths)</p>
</blockquote>
<p></p>
<p></p> Hello,
Thank you very much f…tag:www.grasshopper3d.com,2014-01-23:2985220:Comment:9953442014-01-23T09:33:17.835ZIonut Antonhttps://www.grasshopper3d.com/profile/ionutanton
<p>Hello,</p>
<p></p>
<p>Thank you very much for the thourough explination, it realy makes sense when written like this.</p>
<p>Also i like the fact that you pass a list of tree branch values for the parallel function. I saw that it can only handle one list of items but coudnt figure out what to use. Yours is a very elegant function.</p>
<p>As far as notations, this was my first python script and the coding was quite sloppy. Im still getting the hang of it.</p>
<p></p>
<p>The good point is that…</p>
<p>Hello,</p>
<p></p>
<p>Thank you very much for the thourough explination, it realy makes sense when written like this.</p>
<p>Also i like the fact that you pass a list of tree branch values for the parallel function. I saw that it can only handle one list of items but coudnt figure out what to use. Yours is a very elegant function.</p>
<p>As far as notations, this was my first python script and the coding was quite sloppy. Im still getting the hang of it.</p>
<p></p>
<p>The good point is that it works like a charm.</p>
<p></p>
<p>Tahnks again.</p>
<p></p>
<p>Ionut</p> Hi Ionut,Parallel's run funct…tag:www.grasshopper3d.com,2014-01-22:2985220:Comment:9951502014-01-22T20:04:03.631Zdjordjehttps://www.grasshopper3d.com/profile/djordje
<p>Hi Ionut,<br></br><br></br>Parallel's run function needs some list or tuple to work on.</p>
<p>That leaves the original Brep data tree out of it. But you can use the branches paths as a list:</p>
<blockquote><p>import Rhino<br></br>import ghpythonlib.parallel<br></br>import Grasshopper.Kernel.Data as ghp<br></br>import Grasshopper.DataTree as ghdt<br></br><br></br>newTree = ghdt[Rhino.Geometry.Brep]()<br></br>paths = x.Paths<br></br><br></br>def boolD(_paths):<br></br> diff =…</p>
</blockquote>
<p>Hi Ionut,<br/><br/>Parallel's run function needs some list or tuple to work on.</p>
<p>That leaves the original Brep data tree out of it. But you can use the branches paths as a list:</p>
<blockquote><p>import Rhino<br/>import ghpythonlib.parallel<br/>import Grasshopper.Kernel.Data as ghp<br/>import Grasshopper.DataTree as ghdt<br/><br/>newTree = ghdt[Rhino.Geometry.Brep]()<br/>paths = x.Paths<br/><br/>def boolD(_paths):<br/> diff = Rhino.Geometry.Brep.CreateBooleanDifference(x.Branch(_paths),y.Branch(_paths),0.01)<br/> path = ghp.GH_Path(_paths)<br/> newTree.AddRange(diff, _paths)<br/> return diff<br/><br/>if parallel:<br/> ghpythonlib.parallel.run(boolD, paths, False)<br/><br/>a = newTree</p>
</blockquote>
<p></p>
<p><a target="_self" href="http://storage.ning.com/topology/rest/1.0/file/get/2768863170?profile=original"><img width="600" class="align-full" src="http://storage.ning.com/topology/rest/1.0/file/get/2768863170?profile=RESIZE_1024x1024" width="600"/></a></p>
<p>Btw, I use a different notation for importing DataTree and GH_Path, than you. Do not be confused with it.<br/><br/>You may need to refresh your data parameters once you download the attached .gh file (meaning copy the original ones). It's the issue grasshopper issue.</p>