I have a Rhino file with a lot of layers. Each layer includes surfaces which needs to be joined. This task takes some time, because I need to go through every layer and join the surfaces separately.
Is there a way to just select the whole model and have a routine which joins the surfaces layer by layer.
The expected result is that the surfaces from a layer are joined but not joint to the surfaces form the other layers.
By the way this question is not related to my “Mesh topology across polysurfaces?” topic.
Here is a quick hack… Actually this also joins curves and meshes. Hang on a bit…
Script gives you choice of what types of objects you want to join, remembers your choice within the same session.
One more edit: added the possibility to select a range of layers, not just all layers…
"""Joins curves, surfaces/polysurfaces, meshes by layer.
Choice of object type and layer range. Script by Mitch Heynick 08.04.15"""
import rhinoscriptsyntax as rs
import scriptcontext as sc
#Get previous settings
if "JBL_Crvs" in sc.sticky: crv_x = sc.sticky["JBL_Crvs"]
else: crv_x = True
if "JBL_Srfs" in sc.sticky: srf_x = sc.sticky["JBL_Srfs"]
else: srf_x = True
if "JBL_Meshes" in sc.sticky: mesh_x = sc.sticky["JBL_Meshes"]
else: mesh_x = True
if "JBL_LayerChoice" in sc.sticky: lay_x = sc.sticky["JBL_LayerChoice"]
else: lay_x = True
choice=[(items[i],"No","Yes") for i in range(3)]
gb=rs.GetBoolean("Items to join?",choice,[crv_x,srf_x,mesh_x,lay_x])
if gb and (gb+gb+gb+gb)>0:
layers=rs.GetLayers("Select layers to join objects")
if not layers: return
for layer in layers:
crvs= ; srfs= ; meshes=
for obj in objs:
elif rs.IsBrep(obj) and not rs.IsObjectSolid(obj):
if gb and len(crvs)>1: DoJoin(crvs)
if gb and len(srfs)>1: DoJoin(srfs)
if gb and len(meshes)>1: DoJoin(meshes)
sc.sticky["JBL_Crvs"] = gb
sc.sticky["JBL_Srfs"] = gb
sc.sticky["JBL_Meshes"] = gb
sc.sticky["JBL_LayerChoice"] = gb
As a file:
JoinByLayerWithChoice.py (2.0 KB)