It worked fine in R7, and I’m trying to make it fit for R8.
The script detects the type of the viewport (“StandardModelingViewport” or “DetailViewport”), and turns off the layer’s local or global visibility given by a command option.
It works in a detail viewport, but the method
does not seem to work for model space viewports. Is there another way to access this new “local” layer visibility, or is this a bug, or something unexposed yet?
import Rhino
import scriptcontext as sc
def layers_modelview_off():
rc, selected = Rhino.UI.Dialogs.ShowSelectMultipleLayersDialog(None, "Select layers to turn model views off:", False)
if not rc: return
for index in selected:
layer = sc.doc.Layers[index]
if layer and layer.ModelIsVisible:
new_layer = Rhino.DocObjects.Layer()
new_layer.CopyAttributesFrom(layer)
new_layer.ModelIsVisible = False
sc.doc.Layers.Modify(new_layer, layer.Id, True)
if __name__ == "__main__":
layers_modelview_off()
In R8, it works for all ‘spaces’ - model, layout, detail, and asks if the layers should be hidden globally or locally (In R7, when in model space, the layers are turned off immediately).
By the way: the new Script Editor in R8 became pretty cool, congratulations!