RhinoCommon Brep.JoinBreps result differs from Join command

Hi guys,

Seems like the RhinoCommon method yields in different results than the join command. How do I recreate the result I get from the Join Command in RhinoCommon?

Can be recreated using the file & code below.


220224 JoinBreps problem.3dm (102.6 KB)

import Rhino
import scriptcontext as sc

def test_joiner():
    filter = Rhino.DocObjects.ObjectType.Surface | Rhino.DocObjects.ObjectType.PolysrfFilter
    rc, objref = Rhino.Input.RhinoGet.GetMultipleObjects("Select surface or polysurface to join", False, filter)
    if not objref or rc != Rhino.Commands.Result.Success: 
        return
    
    breplist = []
    
    for i in objref:
        brep = i.Brep()
        if not brep:
            continue
        breplist.Add(brep)
    
    joinBrep = Rhino.Geometry.Brep.JoinBreps(breplist,sc.doc.ModelAbsoluteTolerance)
    
    if joinBrep:
        for b in joinBrep:
            sc.doc.Objects.AddBrep(b)            
    sc.doc.Views.Redraw()

if __name__=="__main__":
    test_joiner()

Hoi Siemen,

What if you Join with sc.doc.ModelAbsoluteTolerance*2.1

I believe in rhinoscripysyntax joining uses that tolerance as well.

2 Likes

Thanks @Willem! That seems to work. I didn’t try the rhinoscriptsyntax method.

I have to say that these hardcoded values are hard for me to understand the logic behind it. Like, who comes up with these and how do they get to these specific numbers. :thinking:

I’m always using a factor of 2.1 where 2 trimmed curves or surfaces are involved.
This value is also used in rhinoscripysyntax for joining curves and surfaces.

My reasoning for using 2.1 is:

If 2 surfaces are trimmed by eachother with tolerance_x both are allowed to be tolerance_x away form the other surface.
So In theory they can be 2 * tolerance_x apart.
However since we are dealing with floating point numbers they can be more that that apart when tested.
Thus multiplying with 2.1 adds 5% extra tolerance to catch those edge cases.

Makes sense?

Groet en fijne avond
-Willem

1 Like

That makes a lot of sense. Thanks a lot for the explanation!