# Performing boolean difference on multiple layered curves

Hi, I’m looking for a way to perform a boolean on any amount of curves at once in a sequence.

See this example:

And the GH file:
boolean_question_multiple.gh (13.2 KB)

I’ve tried different ways by using:

Clipper:
The issue is that it keeps the lines around the bottom edge with clipper, this means double lines where the curves intersect, which are unwanted.

(sorry for the messy drawing, I have a double wrist injury)

Make2D:
First making sure the curves are extruded into solids and placed on top of each other in the z-direction, but it didn’t work out for me as the curves that should be invisible, are still visible somehow despite getting the layering correctly.

Furthermore, I couldn’t find out how to use clipper to perform a repeating boolean that takes the previous shape and booleans it with the next one. It should at the same time perform a join boolean on all of the curves that are on top of the next, this shape will be used as the subtraction curve. This is because it also has to work with irregular curvy shapes that might sometimes cover also the second and third object underneath it.

So I think it works like this:

1. Take curve 1
2. Subtract curve 1 from curve 0
3. Join curve 0 and 1
4. Subtract the result of the join from curve 2
5. Join curve 0, 1, 2
6. Subtract that join from curve 3
7. Join curve 0, 1, 2, 3
8. Subtract that join from curve 4

All curves should be closed curves if it is done this way so it knows outside and inside.
It should do this, but it should also remove the lines where both curves share a boundary to make sure we don’t end up with double curves.

Now I’m working on a generator that generates multiple shapes at once, so for five items, sure, I can make a boolean stream with the output of the previous boolean being plugged into the next boolean (still an issue with double lines though), but I want to see if I can make it as flexible as possible and have the script generate this loop by itself, no matter how many curves are being plugged in.

This project has been on my wishlist since forever and I had hoped to be able to create this after a few months, but I have to give in and ask for advice. I have checked just about any topic on this but nothing that features an issue like this. Maybe I’m looking in the wrong corner.

If anything’s unclear, let me know!

You could reduce redundant parts of your def. like the attached however, your description sounds like self-contradictory and I don’t think that’s even possible.

boolean_question_multiple_re.gh (11.8 KB)

1 Like

I was trying to recreate something similar to this in the end:

It’s a work I once created over a year ago with a line generator. But I was never able to work out how the overlapping lines were subtracted to make it appear so that they actually overlap as if they are surfaces covering each other.

Also I was inspired by the ‘Unknown Pleasures’ album cover by Joy Division:

I can see how the structure looks, I kind of understand what’s needed to achieve this, but I don’t know how to make it without trimming each individual line manually. The works in the images were created by a script, so it must be possible. I’m just not understanding how it’s done.

This is why I tried to approach it as if the overlapping curves were actually closed curves. I had the idea to boolean subtract them and then remove the parts I didn’t need. But maybe it is done in some other way that I’m not understanding.

And thanks for sharing part of the solution for doing multiple booleans, I learned a lot from how you solved it. Very, very useful, also in the future for other projects that require a similar kind of almost recursive solution (can I call that recursive in a way?).

i am very fascinated by this little project of yours.
I actually think of ways to do it in C# and would like to give it a try tonight.
but Is your problem solved anyway?

The sequential boolean part is solved yes, but the part with the double lines where the boundaries of the resulting curves meet isn’t.

Did you see my reply to HS_Kim where I share my eventual idea that I plan to work towards to?

If it is of any help, this is an example of the code for the Unknown Pleasures album cover:

For those that know how to code, it shows how the clipping of curves is done
I’m just not such a good coder and I was looking for ways to achieve this in Grasshopper with components alone.

But I’m also quite interested in what you come up with nonetheless! It’s more of a self-exercise, so it’s great to see the multiple ways things can be handled.

Some more:

Yes the ways you proposed should work.
But if you do it with grasshopper component, the “recursive” part of the script will be 1000 times slower than it is done in C#. maybe 20 times slower than in Python.

This will get out of hand if you have several hundreds intersecting curves.

IMHO, you could use Make2Din most of the cases like your reference drawings, BTW as you can see, it shows some glitches so, it’s not always perfect unless you have very simple geometries… Anyway you can edit some unwanted curves afterward.

Make2d_re.gh (13.9 KB)

2 Likes

Wow, your results look so much more elegant than mine. Meanwhile I was trying to achieve the same, but my renders look like this (and this is why I thought Make2D wasn’t a good solution, but you’re showing me it can be a solution after all):

I think that maybe your solution has them spaced apart more, this is the sideview of what I’m trying to `Make2D`:

Edit:
Nvm, increasing the distance makes it worse in my case:

Way more buggy.
And my definition is too long to even see in one screen:

I will inspect yours and see what I can learn from it. Thanks for thinking along.

By the way, do you use some kind of Bifocals alternative to show the component names above the components? It looks very useful!

Ps sorry, forgot to share my definition so you can see how crappy my attempt was:
wavegen_lines_v4.gh (19.3 KB)

I made a quick (probably not very efficient) attempt with Python.

boolean_question_multiple_v2.gh (16.6 KB)

1 Like