I needed this today…

Here’s a quick python implementation for it, someone will need it someday

```
# Enable Python support and load DesignScript library
# IMPORTANT : ALL DYNAMO DESIGN SCRIPT NODES ARE AS (dg)
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript import Geometry as dg
from itertools import groupby
planes=UnwrapElement(IN[0])
planes = list(set(planes))
def flatten(x):
result = []
for el in x:
if hasattr(el, "__iter__") and not isinstance(el, basestring):
result.extend(flatten(el))
else:
result.append(el)
return result
norms = []
wantedplanes = []
for p in planes:
norms.append(p.Normal)
closest = []
bigcount = 0
for n in norms:
bigplane = planes[bigcount]
bigcount += 1
tmp = []
tmp_plane = []
tmp_close = []
smallcount = 0
for n2 in norms:
smallplane = planes[smallcount]
angle = round(dg.Vector.AngleWithVector(n,n2),2)
if angle == 0 or angle == 180:
tmp.append(True)
smallorigin = smallplane.Origin
tmp_close.append(smallorigin)
tmp_plane.append(smallplane)
smallcount += 1
if tmp.count(True) != 0 and len(tmp) != 0:
wantedplanes.append(tmp_plane)
closest.append(tmp_close)
wantedplanesclean = []
for x in wantedplanes:
if x not in wantedplanesclean:
wantedplanesclean.append(x)
wantedplanesclean = (wantedplanesclean)
closestclean = []
for x in closest:
if x not in closestclean:
closestclean.append(x)
closestclean = (closestclean)
goodstuff = []
problems = []
count = 0
for plist in wantedplanesclean:
ptmp = []
gtmp = []
for pl in plist:
clist = closestclean[count]
yesorno = []
for c in clist:
bestpoint = dg.Geometry.ClosestPointTo(pl,c)
yesorno.append(dg.Geometry.IsAlmostEqualTo(c,bestpoint))
if yesorno.count(True) != 1:
ptmp.append(pl)
else:
gtmp.append(pl)
if len(ptmp) != 0:
problems.append(ptmp)
if len(gtmp) != 0:
goodstuff.append(gtmp)
count += 1
OUT = problems
```

Even a further one to actually get unique planes:

```
# Enable Python support and load DesignScript library
# IMPORTANT : ALL DYNAMO DESIGN SCRIPT NODES ARE AS (dg)
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript import Geometry as dg
from itertools import groupby
from collections import defaultdict
planes=UnwrapElement(IN[0])
planes = list(set(planes))
def flatten(x):
result = []
for el in x:
if hasattr(el, "__iter__") and not isinstance(el, basestring):
result.extend(flatten(el))
else:
result.append(el)
return result
norms = []
wantedplanes = []
for p in planes:
norms.append(p.Normal)
closest = []
bigcount = 0
for n in norms:
bigplane = planes[bigcount]
bigcount += 1
tmp = []
tmp_plane = []
tmp_close = []
smallcount = 0
for n2 in norms:
smallplane = planes[smallcount]
angle = round(dg.Vector.AngleWithVector(n,n2),2)
if angle == 0 or angle == 180:
tmp.append(True)
smallorigin = smallplane.Origin
tmp_close.append(smallorigin)
tmp_plane.append(smallplane)
smallcount += 1
if tmp.count(True) != 0 and len(tmp) != 0:
wantedplanes.append(tmp_plane)
closest.append(tmp_close)
wantedplanesclean = []
for x in wantedplanes:
if x not in wantedplanesclean:
wantedplanesclean.append(x)
wantedplanesclean = (wantedplanesclean)
closestclean = []
for x in closest:
if x not in closestclean:
closestclean.append(x)
closestclean = (closestclean)
goodstuff = []
problems = []
count = 0
for plist in wantedplanesclean:
ptmp = []
gtmp = []
for pl in plist:
clist = closestclean[count]
yesorno = []
for c in clist:
bestpoint = dg.Geometry.ClosestPointTo(pl,c)
yesorno.append(dg.Geometry.IsAlmostEqualTo(c,bestpoint))
if yesorno.count(True) != 1:
ptmp.append(pl)
else:
gtmp.append(pl)
if len(ptmp) != 0:
problems.append(ptmp)
if len(gtmp) != 0:
goodstuff.append(gtmp)
count += 1
# take X for sort
def takeX(plane):
return plane.Origin.X
intersects = []
for plist in problems:
tmpall = []
for p in plist:
tmp = []
excluded = []
for p2 in plist:
if dg.Geometry.DoesIntersect(p,p2) and p != p2:
tmp.append([p,p2])
flattened = list(set(flatten(tmp)))
sortme = sorted(flattened, key=takeX)
if len(sortme) != 0:
tmpall.append(sortme)
grouped_things = defaultdict(list)
if len(tmpall) != 0:
for thing in tmpall:
grouped_things[thing[0]].append(thing)
fixedthings = []
for gthings in grouped_things:
fixedthings.append(gthings)
intersects.append(list(set(fixedthings)))
pureplanes = flatten([intersects + goodstuff])
OUT = pureplanes
```