Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5783

How Curve.CreateBooleanDifference Method (Curve, IEnumerable) works

$
0
0

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:
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 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[0], curve2)

for crv in bcurve:
sc.doc.Objects.AddCurve(crv)

4 posts - 3 participants

Read full topic


Viewing all articles
Browse latest Browse all 5783

Trending Articles