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 scobj1 = 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:
sc.doc.Objects.AddCurve(crv)
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 scobj1 = 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[0], curve2)
for crv in bcurve:
sc.doc.Objects.AddCurve(crv)