import Rhino
import scriptcontext as sc
def test_intersect_breps():
filter = Rhino.DocObjects.ObjectType.Surface | Rhino.DocObjects.ObjectType.PolysrfFilter
go = Rhino.Input.Custom.GetObject()
go.SetCommandPrompt("Select surfaces or polysurfaces to intersect")
go.GeometryFilter = filter
go.GetMultiple(2, 2)
if go.CommandResult() != Rhino.Commands.Result.Success:
return
brep0 = go.Object(0).Brep()
brep1 = go.Object(1).Brep()
if not brep0 or not brep1:
return
tol = sc.doc.ModelAbsoluteTolerance
rc, out_curves, outpoints = Rhino.Geometry.Intersect.Intersection.BrepBrep(brep0, brep1, tol)
if rc:
for c in out_curves:
sc.doc.Objects.AddCurve(c)
sc.doc.Views.Redraw()
test_intersect_breps()