 # How Curve.CreateBooleanDifference Method (Curve, IEnumerable<Curve>) works

I have a question about the behavior of CreateBooleanDifference.

I want to get a green curve by subtracting a blue curve from a red curve.

Curve.CreateBooleanDifference Method (Curve, IEnumerable), the result is as shown below.

Is this behavior correct?
Below is a sample code and sample model
CreateBooleanDifference.3dm (24.9 KB)

import rhinoscriptsyntax as rs
import Rhino.Geometry as rg
import scriptcontext as sc

obj1 = rs.GetObject(“Get the first closed, planar curve.”)
obj2 = rs.GetObjects(“Get curves to subtract from the first closed curve.”)

curve1 = rs.coercecurve(obj1)
curve2 = [rs.coercecurve(ob) for ob in obj2]

bcurve = rg.Curve.CreateBooleanDifference(curve1, curve2)

for crv in bcurve:

We avoided the problem by creating the first boolean outline as shown below.
Is there anything else I can do?

import rhinoscriptsyntax as rs
import Rhino.Geometry as rg
import scriptcontext as sc

obj1 = rs.GetObject(“Get the first closed, planar curve.”)
obj2 = rs.GetObjects(“Get curves to subtract from the first closed curve.”)

curve1 = rs.coercecurve(obj1)
curve2 = [rs.coercecurve(ob) for ob in obj2]

unionList = [curve1]
unionList.extend(curve2)
ucurve = rg.Curve.CreateBooleanUnion(unionList)

bcurve = rg.Curve.CreateBooleanDifference(ucurve, curve2)

for crv in bcurve:

``````import rhinoscriptsyntax as rs
import Rhino.Geometry as rg
from scriptcontext import doc
curve_a = rs.GetObject("First closed, planar curve", rs.filter.curve)
curves_b = rs.GetObjects("Curves to subtract from", rs.filter.curve)
curve_a = rs.coercecurve(curve_a)
curves_b = [rs.coercecurve(x) for x in curves_b]
result = rg.Curve.CreateBooleanDifference(curve_a, curves_b)
``````

CurveBooleanDiffrence.py (412 Bytes)

1 Like

Hi, @Mahdiyar Thank you for the reply.

That means that the first array is always the outline of the difference result.
However, this does not work well when there are multiple outlines to be acquired, as shown in the figure below.

CreateBooleanDifference.3dm (26.5 KB)

Thank you

This is a different approach maybe:

CurveBooleanDifference.py (4.8 KB)

2 Likes