Hi!
I am trying to write script to boolean objects to each other one by one (first, boolean 2nd to first, then boolean 3rd to the result of previous boolean, ect.) due to boolean not working in Rhino. But I am getting a bug that I am trying to cast Brep into Brep (I was just making a list)
But once pass the ‘Union’ variable back into this function you are providing the wrong argument type. You need to check if you have an array of length 1, and then pick the first item. In a dynamic typed language like Python it is very important to double-check types during runtime! Or let me tell it differently, once you run into a problem, the first thing to do is to debug if you are passing the correct argument types.
Other than Tom’s points … for the general case of this (i.e. any valid Brep/Mesh collection) I would advise to Cluster for Ccx Events your items first (using - for speed [large collections etc etc] - some pre-filter like Box/Box x/y/z Intervals bool ops) and then union on per Cluster branch.
PlanB would be a Recursive approach.
Notify if you think that a C# demo would be useful (but you can’t auto translate C# to P)…
Thanks for your help! Could you please explain more on:
1 the Cluster and Ccx thing (what it is)
2 why use C#. Is it any different from python?
Thanks again!
Thanks for your help! The geometry I was using was not mine to share, sorry!
The strange thing is, if I select-all in rhino and do the boolean union, it works. But when I have it as list of objects in rhino (going into python script), it stops working!
Clustering is a way of “grouping” objects based on some sort of criterion. Is paramount in any serious AEC/ME oriented design approach (data mining etc etc). Given the opportunity for this case the Clustering is called flat hard. Various types of Clustering exist … and some have names: like the K-Means,
In this case the criterion is: mutual Ccx Events. The Result is an indices Tree where each branch contains the indices of Breps that should yield an Array of size 1 (if they are all valid etc etc) if they are all used as input to the R BoolUnion Method.
BTW: for the Clustering “pre-filter” Box technique mentioned. First have in mind that ANY opp has a cost. Anyway … imagine extracting all the Boxes from the Breps in the collection (that’s rather fast). If 2 given Boxes don’t intersect (use their x/y/z Intervals for checking that) then the Breps are isolated. If they intersect then the Breps MAY intersect (or may not). For instance imagine 2 doughnuts (where the one is inside the other): their Boxes Intesect but the yummy things are isolated.
That sort of stuff … meaning that … well … there’s no such thing as a free Big Mac.
Other than that C# is vastly different to P. But in order to explain the benefits and/or differences and/or this or that (most notably in the AEC market sector) … we’ll need a year (and a half).