# 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

1 Like

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[0]

out = []
while len(intersections) > 0:
first, rest = intersections[0], 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

8 Likes

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

1 Like

Thomas,

Thank you!!

Hi Thomas,

Thank you for the python code. I use it in one of my scripts.
Since i am new to python I have a additional question. Could you add another level to the script?
The input cubes in the example above is a flat list. However I have a script where i start with a three level list.

The expample below shows that I got the surfaces from walls, one of the walls is divided into two ‘solids’. This is why i have a three layer list.
I want to group the wall surfaces based on their intersection (in their own list, not to a flat list of all the wall surfaces) to later create a ‘cell’ with Topologic.

Kind Regards,

Martin

Share rvt and dyn files, please.

And try:

2 Likes