Rhino.Geometry.Intersect.Intersection.BrepBrep() bugged

Run this on bad output.3dm (42.5 KB)

import Rhino
import scriptcontext as sc
import rhinoscriptsyntax as rs

j = rs.GetObject()
k = rs.GetObject()

chk = Rhino.Geometry.Intersect.Intersection.BrepBrep(rs.coercerhinoobject(j).Geometry, rs.coercerhinoobject(k).Geometry, sc.doc.ModelAbsoluteTolerance)
sc.doc.Objects.AddCurve(chk[1][0])


This kind of overlap works as intended:

This seems to work in Rhino 7:

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()

– Dale

A post was split to a new topic: Clash Detection