Hi!
I´m trying to find a good method for finding parallel planes (or faces) in a box and then group them in pairs.
I attach my grasshopper definition so far. I managed to find the parallels but I struggle to get just a tree with three branches (one for each pair of parallel planes) with the indices of the faces composing the pair as item on such list. Instead I have a tree composed of 6 branches (one per each face) with the pairs duplicated. Also, I have the feeling that the definition is a little bit dirty. There must be a simpler way to accomplish the same goal with less.
Just out of interest, I thought I would give it a go in Python:
import rhinoscriptsyntax as rs
import itertools as it
import ghpythonlib.treehelpers as th
bfaces = rs.ExplodePolysurfaces(x)
pfaces = []
for i in it.combinations(bfaces,2):
nmls = []
for j in i:
cpnt = rs.SurfaceAreaCentroid(j)[0]
param = rs.SurfaceClosestPoint(j, cpnt)
nmls.append(rs.SurfaceNormal(j, param))
if rs.IsVectorParallelTo(nmls[0], nmls[1]):
pfaces.append(i)
a = th.list_to_tree(pfaces)
Get the general case (impossible without code): an elementary Hard Flat Clustering task (if you can read C# … see the classic/standard HFC Method used + the related BINFO Class).
Hey @martinsiegrist. Thanks so much for the quick answer. It saved my b***. Sorry for not having come back before. I had no time, so I basically took your def and inserted it into mine. Everything worked like a charm.
Hey there @PeterFotiadis. I checked your solution the first. It was impressively complete. But although I could detect and group parallel faces among several BREPs, I could do that in the same BREP. I must have done something wrong. Anyway, thanks soo much for the quick hand.
Hey @11159. Thanks so much for your help. Quite an interesting method. I definitely need to sit down and study it. Specially the use of crossref and the filtering you did before. Thanks so much!
Well … I do hope that I haven’t skipped some line (you never know) in the Clustering Method (or in the Class definition and/or the sampling phase - but that is more or less highly unlikely since each Face from each Brep is sampled in the bInfo List).
Hey @anon39580149, I used that method before. It seems the way to go at the beginning. I do not know how but I found the case where I had values in y that were exactly as in z and then it could not separate them in pairs. Maybe I just did something else wrong. Thanks anyway. I really appreciate your effort.
The Clustering algo stores (in some given Cluster [of bInfo Type]) each Face that has a Normal angle (to any other Normal) LESS that delta. So the above Faces have Normals heading North/South (they are anti papallel).
But obvioulsy I could add an option for that: a 2nd delta => delta2 = Math.Abs(Math.PI*2 - delta).
BTW: If you can read C# see the rather primitive filter used on Faces. So there maybe I could add an option or two (say: take only faces that have 2 holes or are pig ugly or are smaller than this or greater than that or are adjacent to 666 others … etc etc)…