Right now rs.JoinSurfaces() is a really dumb function - and it doesn’t need to be. The current wrapper code is this:
def JoinSurfaces(object_ids, delete_input=False):
"""Joins two or more surface or polysurface objects together to form one
polysurface object
Parameters:
object_ids ([guid, ...]) list of object identifiers
delete_input (bool, optional): Delete the original surfaces
Returns:
guid: identifier of newly created object on success
None: on failure
Example:
import rhinoscriptsyntax as rs
objs = rs.GetObjects("Select surfaces in order", rs.filter.surface)
if objs and len(objs)>1: rs.JoinSurfaces(objs)
See Also:
ExplodePolysurfaces
IsPolysurface
IsPolysurfaceClosed
IsSurface
IsSurfaceClosed
"""
breps = [rhutil.coercebrep(id, True) for id in object_ids]
if len(breps)<2: return scriptcontext.errorhandler()
tol = scriptcontext.doc.ModelAbsoluteTolerance * 2.1
joinedbreps = Rhino.Geometry.Brep.JoinBreps(breps, tol)
if joinedbreps is None or len(joinedbreps)!=1:
return scriptcontext.errorhandler()
rc = scriptcontext.doc.Objects.AddBrep(joinedbreps[0])
if rc==System.Guid.Empty: return scriptcontext.errorhandler()
if delete_input:
for id in object_ids:
id = rhutil.coerceguid(id)
scriptcontext.doc.Objects.Delete(id, True)
scriptcontext.doc.Views.Redraw()
return rc
The problem is here:
The result is thus forced to be exactly one brep, and if it isn’t, the script simply fails and returns None
.
But Rhino.Geometry.Brep.JoinBreps() is perfectly capable of joining a collection of diverse breps, it joins what it can and returns a list of both the joined parts plus anything that was not able to be joined. Unfortunately the line above simply throws out any result of this method other than one single joined brep.
If you can’t change this method, please add a new method rs.JoinBreps() that does work to join multiple possibly disjoint breps into whatever can be joined (like the command Join now does).
BTW, the Help sample also indicates you need to select the surfaces in order, but this is not in fact necessary.