I imported an assembly where each layer is a part, but they came as individual surfaces, not polysurfacse/solids. I’d love to have a quick way to run a script that looks at my file and joins all the surfaces on the same layer/sublayer? right now it looks like this (with lots of scrolling):
Are you familiar with running python scripts?
Below the script that will automate what you want.
It is bare and maybe slow but that’s all I have time for right now.
I advice you to test it on a subset of your file first
import rhinoscriptsyntax as rs
def JoinByLayer() :
layer_list = rs.LayerIds()
for layer_id in layer_list:
rs.UnselectAllObjects()
rs.SelectObjects(rs.ObjectsByLayer(layer_id))
rs.Command('_Join')
if( __name__ == '__main__' ):
JoinByLayer()
Going to suggest a small improvement to Willem’s script… Cut the redraw to go a bit faster and a check to not run join if there are no objects selected (layer empty, all objects locked, etc…) or just one…
–Mitch
import rhinoscriptsyntax as rs
def JoinByLayer() :
layer_list = rs.LayerIds()
rs.EnableRedraw(False)
for layer_id in layer_list:
rs.UnselectAllObjects()
rs.ObjectsByLayer(layer_id,True)
objs=rs.SelectedObjects()
if objs and len(objs)>1: rs.Command('_Join')
if( __name__ == '__main__' ):
JoinByLayer()
Oh yeah, I forgot, just remove the “if name == main” line, and out-dent the line below it. Doesn’t work in a toolbar button with “if name == main”. Sorry for the disinformation…
Like so:
! _-RunPythonScript (
import rhinoscriptsyntax as rs
def JoinByLayer() :
layer_list = rs.LayerIds()
rs.EnableRedraw(False)
for layer_id in layer_list:
rs.UnselectAllObjects()
rs.ObjectsByLayer(layer_id,True)
objs=rs.SelectedObjects()
if objs and len(objs)>1: rs.Command('_Join')
JoinByLayer()
)