# Is there a 2D version of Boolean difference? How to subtract one 2D shape from another?

Hello,

Is there a 2D version of Boolean difference where you can subtract one 2D shape from another?
http://docs.mcneel.com/rhino/5/help/en-us/commands/booleandifference.htm
For example, you have have a three 2D rectangles and the largest one overlaps with two smaller ones. You need to subtract the two smaller 2D rectangles from the larger one in order to have a unique “E” shaped profile which you would then extrude.

Thanks for any guidance you can provide.

I just discovered the SPLIT command which achieves this with 2D surfaces but not rectangles. Are there any other options?

Daniel,

Try Curve>Curve Edit tools> Curve Boolean.
http://docs.mcneel.com/rhino/5/help/en-us/commands/curveboolean.htm

1 Like

Even though I think CurveBoolean is a super nice tool I sometimes think it would be nice to be able to do a boolean difference instead of having to click inside all the areas I want…

2 Likes

Split works with lines and curves as well as surfaces. The Trim command can also be used. The sequence of use may be somewhat different than using Boolean commands.

Start the Trim command and select the large rectangle as the cutting object. Select the smaller rectangles where they coincide with the large rectangle to trim that part of the small rectangle.

Start the Trim command again and select the remaining parts of the small rectangles as the cutting objects. Select the parts of the large rectangles between the legs of the small rectangles to trim.

Join the remaining parts into the E shape.

1 Like

Here is a hack of a tool to do this - it works like BooleanDifference between solids - in fact that’s exactly what it’s doing behind the scenes. Select two sets of closed, planar curves - the first to subtract from, the second to subtract with. If the curves are not all coplanar, it will warn you and let you either project all to the active CPlane or abort. Option to delete input curves or not when picking the second set (sticky within the session).

CurveBooleanDifference.py (4.7 KB)

– Mitch

3 Likes

Awesome Mitch. Thanks!

I’ve made a button for the script. How do I assign it to run when clicking the button? I don’t know what I’m doing so tried this in the button command

_RunPythonScript
C:\Program Files\Rhino 6\System\Rh6PythonScripts\CurveBooleanDifference.py

That only take me to the script. I then have to select it. What is the correct syntax so the script will run on button press?

Try this:
-_RunPythonScript (C:\Program Files\Rhino 6\System\Rh6PythonScripts\CurveBooleanDifference.py)

That works! Thanks.

Hi Mitch,
Thanks for sharing. I’m really excited to use this but could you please give me some guidance on how/where to install your *.py file? I haven’t done it before.
Thanks again,
Dan

Would It be possible to have this script work for open curves?

No, unfortunately not, for that only the normal CurveBoolean will work currently. What is it you are trying to do that CurveBoolean won’t accomplish?

Could well be that I am not using CurveBoolean properly but I wasn’t able to have it produce the result I am looking for.

I have included some Images, the first image is the before and the second; the desired result. Ah I should note that the horizontal curves are open.

Well, with stuff like that it’s hard to decide what to keep and what to throw away automagically… Best you can do in this situation I think is select all, call CurveBoolean, click somewhere outside the whole thing, then start clicking inside in the areas you want to delete. You will see a preview of what Rhino proposes to keep.

However, in some cases, if some of the curves are closed and you want to eliminate other open curves that are inside them, you might be better served with Trim and various combinations of window selecting, SelFence, and SelBrush to get rid of what you don’t want.

1 Like

Right I’ll give that a shot then.

V5 Mac here unfortunately, but I had totally forgotten about those useful selection commands thanks for the reminder.