A little advice about rs. JoinSurfaces () function


Hello everyone

Like this kind of situation.
I want to join four surface,If use BrepJoin Components or Rhinocommon will return One open brep and two Untrimmed Surface.But I use rs. JoinSurfaces () function will return null.
Because JoinSurfaces function only returns a polysurface object,
So I hope:
Put this code

(if joinedbreps is None or len (joinedbreps)! = 1:
Return scriptcontext. Errorhandler ()
Rc = scriptcontext. Doc. Objects. AddBrep (joinedbreps [0]))

Modified to

If joinedbreps is None:
Return scriptcontext. Errorhandler ()
Rc = [scriptcontext. Doc. Objects. AddBrep (joinedbreps [I]) for I in xrange (len (joinedbreps)]

This file
JoinSurface_Advice.gh (10.3 KB)




Maybe use Rhino.Geometry.Brep.JoinBreps(breps,tol) instead?

This works here with your geometry (not tested in GH)

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino

srfs=rs.GetObjects("Select surfaces",8,preselect=True)
breps=[sc.doc.Objects.Find(srf).Geometry for srf in srfs]



yes,I use Rhino. Geometry. Brep. JoinBreps (breps, tol) instead,It is very perfect.But I still want to rs. JoinSurfaces () function can return multiple polysurface .


Yes, you have a point there. The following is the code for rs.JoinSurfaces()

def JoinSurfaces(object_ids, delete_input=False):
    """Joins two or more surface or polysurface objects together to form one
    polysurface object
      object_ids = list of object identifiers
      identifier of newly created object on success
      None on failure
    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)

    #below is why it fails, it only wants to return one object
    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)
    return rc

Methinks this could be relatively easily fixed… for V6?
It would also require that the vb rhinoscript method be changed as well.

However… It could invalidate existing scripts, as then the method will return a list/array instead of a single GUID…

@stevebaer ? @dale ?


(Dale Fugier) #5

RhinoScript has a JoinSurfacesEx which seems to do what you want. Perhaps we need to add this to rhinoscriptsyntax?


Ahh, yes please! Thanks Dale! --Mitch

(Dale Fugier) #7




Thanks dale