 # Create Group of intersecting solids

Hi I´ve got a number of interesecting solids and wish to group them (put them in different lists).

I have to use the Geometry.DoesInteresect Node instead of the Bimorph interesection nodes, these solids are “virtual” and I don´t want to create DirectShapes to be able to use the Bimorph Element Element Intersection.

As a result of 10 objects I get a list of true and false values.

The list looks something like this (0 = False and 1 = True):

L0 = 1 0 0 0 0 1 0 0 0 0
L1 = 0 1 0 0 1 0 0 0 0 0
L2 = 0 0 1 1 0 0 0 0 0 0
L3 = 0 0 1 1 1 0 0 0 0 0
L4 = 0 0 0 1 1 0 0 0 0 1

Every objects interesects with itself (of course), but my goal is to group all objects which are “somehow” in relation to each other.

If object 3 and 4 intersect each other I wish to group them with the object 10, which collides with object 4.

Does anyone have an idea how to properly “solve” this problem Thanks and kind regards,
Jannis

Here’s a solution using Python to determine the sets of intersections. I think that doing it with OOTB nodes alone is tricky because of the potential levels of nesting required to establish the groups

``````# Adapted from https://stackoverflow.com/a/4842897/8091631

intersections = IN

out = []
while len(intersections) > 0:
first, rest = intersections, intersections[1:]
first = set(first)
lf = -1
while len(first) > lf:
lf = len(first)
rest2 = []
for r in rest:
if len(first.intersection(set(r))) > 0:
first |= set(r)
else:
rest2.append(r)
rest = rest2
out.append(first)
intersections = rest
OUT = out
``````

You can simplify your inputs into Geometry.DoesIntersect by using cross-product lacing, instead of List.OfRepeatedItem

41965_Python.dyn (25.3 KB)

Hope this helps,
Thomas

6 Likes

Thanks a lot This works great!! Exactly what I was looking for 1 Like

Thomas,

Thank you!! 