I’m trying to script ‘a multiple solid intersection,’ but after some attends, it’s not working, what am I doing wrong?

Thanks in advance for your response.

*Shown below a clean version of the script.

20181127 problem multiple breps 00.gh (97.3 KB)

I’m trying to script ‘a multiple solid intersection,’ but after some attends, it’s not working, what am I doing wrong?

Thanks in advance for your response.

*Shown below a clean version of the script.

20181127 problem multiple breps 00.gh (97.3 KB)

Solid difference works on two at a time. Same as Rhino Boolean difference. You will need to make a loop either with a script or looping plugin. Or model that the correct way by developing a node connection system.

```
import rhinoscriptsyntax as rs
import Rhino as rc
out_listBr = []
for i in interA_listBr:
for j in interB_listBr:
out_listBr.append(rc.Geometry.Brep.CreateBooleanIntersection(i, j, 0.01))
```

It is not working, do you know what I am doing wrong?

20181127 problem multiple breps 01.gh (102.6 KB)

Arghh, I cannot figure it out and it is probably very simple.

Its not simple, booleans depend on many factors. Don’t relyb on booleans, this can be made more robust as a node system

Before I searched for the keywords ‘grasshopper node system’ on google, but I did not catch something immediately.

Do you mean by ‘node system’ the ‘crossing points of the intersecting curves,’ or is it something special?

I still wanna know, do some of you who are familiar with python know how to code that?

I have (also uploaded the files three days ago).

```
import rhinoscriptsyntax as rs
import Rhino as rc
out_listBr = []
for i in interA_listBr:
for j in interB_listBr:
out_listBr.append(rc.Geometry.Brep.CreateBooleanIntersection(i, j, 0.01))
```

It’s kinda difficult to achieve, since you would need complex functions (probably recursive ones) and an expanded knowledge of how booleans work, as well as flawless input geometry, for it to work.

Your basic script logic is right, but it’s missing a lot of stuff!

For instance, in your loop, if i equals j, you are trying to intersect the same brep with itself, which would probably not be desirable.

You could prevent this by simply calling `if i != j:`

before trying to intersect.

You could also try to check for simpler and less costly curve intersections before doing the final boolean ones:

```
if rs.IntersectBreps(brep1, brep2) != None:
# continue with boolean intersection
```

Furthermore, you would need a recursive way to do the intersections, meaning sort of a chain reaction that starts with a brep and intersects it with all the other intersecting breps, meaning not only all of the breps that intersect with the first brep, but all other breps that intersect with breps that intersect with the first brep, but not forcibly with the first brep themselves.

1st recursion:

- 1 intersects with 2, 3, 4, 6, 7, 8, 9

2nd recursion level (intersecting children of brep 1):

- 2 intersects with 3, 5, (1), 8, 9;
- 3 intersects with (2), 4, 5, (1), 8, 9;
- 4 intersects with (3), 5, (1), 9, 8
- 5 intersects with (2), (3), (4), 6
- 6 intersects with (5), (1), 8, 9

… and so fourth

Also, you would have to implement a way to keep track of what has already been intersected, so you don’t produce duplicate geometry. Above the breps between parenthesis should not be intersected again, since they already had an intersection with the brep! This could be done with lists, list of lists or even dictionaries where you could save the information.

As already mentioned above a node based approach would be a lot simpler.

What geometry do you start with? How do you generate the breps?

Why do you even need the intersections?

Thank you Pirateboy for the code. I read your message and it explains me a lot of things, thank you again.