Previous layer state & Isolate layers of selected objects

Hello!

I’m an advanced 2D/3D user of both Autocad and Rhino. Rhino is an excellent application. Much better for 3D modeling than Autocad, especially viewport manipulation and 3D performance. But in the field of layer manipulation, I find Autocad much better than Rhino. I miss “Previous Layer State” (without saving layer state with Layer state manager) and “Isolate Layers of selected objects” option. Are there some way to implement this option in Rhino 6.

Thanks!

Igor

Hello, I’ve got the same question. I need to isolate layers and like to go back to the previous layerstate.
@Helvetosaur you know how to do this by chance or somebody else?
Thanks,
Wolf

You can use the below python scripts to isolate the selected object layer and then restore previous layer state.

Isolate selected object layer:

import rhinoscriptsyntax as rs

#get object and find layer it is on
obj = rs.GetObject('select an object on the layer to isolate')
layer = rs.ObjectLayer(obj)
isCurrent = rs.IsLayerCurrent(layer)
#Save Current layer state
plugin = rs.GetPlugInObject("Rhino Bonus Tools")
if plugin is not None:
    plugin.SaveLayerState("Isolate_Layer")

#Find all current layers
allLayers = rs.LayerNames()

#Make select obj current layer
if isCurrent == False:
    rs.CurrentLayer(layer)

#Hide Layers not including selected object
allLayers.remove(layer)

for L in allLayers:
    rs.LayerVisible(L,False)

Restore Layer State:

import rhinoscriptsyntax as rs

 #Restore Layer state
plugin = rs.GetPlugInObject("Rhino Bonus Tools")
if plugin is not None:
    plugin.RestoreLayerState("Isolate_Layer")

#Deleate Layer state
plugin.DeleteLayerState("Isolate_Layer")

I’m sure someone else could come up with a more elegant solution but it works for me :slight_smile:

Thank you Thomas,
I’ve installed the phyton script which was the first time for me.
Now when I try to isolate several layers the script taks only one in account and i’ve got a warning for sublayers.
The unisolate command is showing an error, see picture below.
Must the script start with, import rhinoscriptsyntax as rs or with # ?

Thank you,
Wolf

Hey Wolf,

I see that the way I went about it wont work due to how parent layers wont turn off if you’re in a sub layer. I’ve also changed it so you can select multiple objects.

I’ve attached a toolbar with edited code using the ‘hide’ and ‘show’ commands instead, also pasting the code below if anyone wants it.
Isolate Layer.rui (10.7 KB)

Isolate selected objects layer:

import rhinoscriptsyntax as rs


#get object and find layer it is on
obj = rs.GetObjects('select an object on the layer to isolate')

rs.EnableRedraw(False)


#creat list of selected obj layers
selectedlayers = []
for i in obj:
    layer = rs.ObjectLayer(i)
    selectedlayers.append(layer)

#select all objects on each layer

for i in selectedlayers:
    rs.ObjectsByLayer(i,True)
isolate = rs.SelectedObjects()

allObjects = rs.AllObjects()

for i in isolate:
    allObjects.remove(i)


#hide selected objects

rs.HideObjects(allObjects)

rs.UnselectAllObjects()

rs.EnableRedraw(True)

Show objects:

import rhinoscriptsyntax as rs

obj = rs.AllObjects()

rs.ShowObjects(obj)

Let me know if that works for you, I havn’t really tested it myself beyond basic functionality.

Thank you, I’ve created two aliases and it’s working like a charme!

I’ve another question going in the same direction.

Very often I’m working, I FREEZ a layer work, ISOLATE layers, work, etc., and afterwards I will go backwards layerstate by layerstate using an alias. Would this be possible in Rhino?