Detail Layers Visibility RhinoScript

One of the issues we struggle with is detail layer visibility, which has made it impossible to adopt Rhino as our primary CAD system. When you have 20 layouts with 60 details, managing layer visibility in details becomes almost impossible. A simple layer visibility change in model space can affect visibility in lots of details. Saving layer states is buggy so that’s not a viable solution. A solution to this would be a RhinoScript that looks at all details’ layer visibility settings, then sets model space layer visibility such that each layer that is visible in any detail is visible in model space (and if not visible in any detail it is off in model space). Before I jump in and try to create a script, I’m hoping someone has already written one. Has anyone done this?

Of course the best solution would be the ability to ignore model space layer visibility in details, but as far as I know that option has yet to appear.

Hi @rhorsefield,

This is a known limitation with they way layer visibility works. In the future, we hope to disconnect model view layer visibility with that of layout/detail visibility.

There are currently no issues related to this in our issue tracking system. If you are having problems and have a repeatable way of demonstrating, we’d like to see it.

I’m a little confused by this, because if a layer is off in the model, then it is also off in all details. Perhaps I need some clarification on this.


– Dale

“I’m a little confused by this, because if a layer is off in the model, then it is also off in all details.”

This is exactly the problem. Correct me if I’m wrong, but a detail has two independently set layer settings: model space and detail space. Both have to be on to be seen in a detail. But if I go to model space or even another detail and
turn off a layer in model space, that layer is now not shown in EVERY detail, even if a detail has that layer on in its detail layer settings. Thus, changing model space layer settings any detail can affect every detail. What I’m suggesting is a stop-gap measure
until you can divorce the model and detail layers. The script would go through all details, identify which layers are intended to be on in
any detail based on detail-only layer settings, and then set model layers to match.



Hi @rhorsefield

Your one the right track. Each layer has a global visibility setting and can have per layout/detail visibility settings. When a layer is on globally, it can be turned off in one or more layouts/details. However, if a layer is off globally, then it is off everywhere including in layouts/details.

A number of users have expressed the wish of having the global visibility disconnected from the layout/detail visibility. In this scenario, the layer could be off globally but still be visible in layouts/details. There is a significant amount of plumbing changes to make this fix. I don’t see it happening in Rhino 7, certainly not in Rhino 6.

– Dale

Are you aware of a script that does what I discussed?



But does this solve your issue? It could then well be that turning on layers globally means it will screw up other details that were not supposed to see those layers. I think the safest is to do your layout work when all layers are on and then set the details layer state where needed. Or do you want to run this script per page, print the page and go to the next?

what exactly? I must say I don’t use it that often, but when I do it works.

It’s been a while that I’m waiting for a more convenient layout management.
Knowing that it won’t be part of version 7 pushed me to try something by my own.
I’m working on a python script which does 3 basic functions :

  1. When switching to layout space, model layer states are saved and every model layer states are then turned on.
    When switching to model space model, model layer states are restored.
    This way we clearly see detail space states.
    Note : To print, whether turn all model space layer on manually or be in layout space.
  2. When new layer is created, it is turned off in every details (detail space).
  3. If shift is down while the new layer button is pressed, it behaves “normally” and it leaves the new layer on in every details.

Notes :
It actually works on a Windows 10 x64 platform.
The shift key detection is windows dependent. Must be tested on Mac.
The code basically registers two events : RhinoView.SetActive and RhinoDoc.LayerTableEvent.

It seems to work for me so far.
Please feel free to give me feedback.

Regards. (3.9 KB)


Hello all

I was having tons of issues with layer visibility in detail view too.

I made a script that lets you turn off selected layers in the details views on the current layout… this has helped me save alot of time, especially after I have added model in new layer and those new elements show up in my old details.

In the code, you have the abilities to:

  • select layer from a rs.MultiListBox
  • set visibility of the selected layer ON or OFF
  • Apply to all details views on the current layout, or, apply to details you’ve selected

This is saving me time, so I thought I’ll share the code. It may not solve problems for everyone but maybe the code can be adapted and/or improved.

I’m also new to Rhinocommon. The script is using rs.command so it’s not optimised, I’d like to know how to optimise it with Rhinocommon

I think this can also be done with a for loop to apply to multiple layouts, not just the current one.

import rhinoscriptsyntax as rs
import Rhino
import scriptcontext as sc

def layerOffInDetails():
    curView = sc.doc.Views.ActiveView

    if type(curView) != Rhino.Display.RhinoPageView:
        print 'The active view is not a layout view!'
    #Get all layers in the current Rhino document
    allLayers = rs.LayerNames()
    ###     SINGLE LAYER INPUT - User is allowed to select one layer only      ###
    #Get user selected layer
    pickedLayer = rs.ListBox(allLayers, title = 'List of all layer')
    #Get layer index from Rhino DocObjects Table
    #sc.doc.layers => Rhino.DocObjects.Tables.LayerTable
    layerTableIndex = sc.doc.Layers.FindByFullPath(pickedLayer, -1)
    #Find document layer by index
    layer = sc.doc.Layers.FindIndex(layerTableIndex)
    ###     MULTIPLE LAYER INPUT    ###
    pickedLayers = rs.MultiListBox(allLayers, title = 'List of all layer')
    if not pickedLayers: return
    layerTableIndexs = []
    for pickedLayer in pickedLayers:
        layerTableIndex = sc.doc.Layers.FindByFullPath(pickedLayer, -1)
    layers = []
    for layerTableIndex in layerTableIndexs:
        layer = sc.doc.Layers.FindIndex(layerTableIndex)
    ###     Visibility Setting ON/OFF   ###
    vis = rs.GetInteger('Set selected layer ON = 1 or OFF = 0', 0, 0, 1)
    #if not vis: return
    result = rs.GetString('Apply to all details or selected details', 'All', ['All', 'Selected'])
    if result == 'All':
        #Select all details from the current view, current should be a layout
        rs.Command('_-SelDetail', echo = 0)
        dvs = rs.SelectedObjects()
    if result == 'Selected':
        dvs = rs.GetObjects('Select details', rs.filter.detail)
    #activate details one by one
    for dv in dvs:
        rs.Command('_-Detail Enable', echo = 0)
        #when detail is activated, set layer visibility 
        #layer.SetPerViewportVisible(sc.doc.Views.ActiveView.ActiveViewportID, vis)
        ###     MULTIPLE LAYER INPUT    ###
        for layer in layers:
            layer.SetPerViewportVisible(sc.doc.Views.ActiveView.ActiveViewportID, vis)
        rs.Command('_-Detail EnablePage', echo = 0)