Control Layout visibility with SetPerViewportVisible

Hi,
to control the layout visibility by layers i tried the following code.

import Rhino as rh

for i in range(len(x)):
    PageView = rh.RhinoDoc.ActiveDoc.Views.Find(x[i],False)
    PageViewPortID = PageView.ActiveViewportID
    LayerIndex = rh.RhinoDoc.ActiveDoc.Layers.Find(y[i],True)
    LayerObj = rh.RhinoDoc.ActiveDoc.Layers.FindIndex(LayerIndex)
    
    LayerObj.SetPerViewportVisible(PageViewPortID,True)
    
    PageView.Redraw()

and the result seems to to work because in the layer panel the visible button (lamp) for the page view is ON but nothing is visible in the page view.

if i double click on the page view to get into the detail view the visibility lamp turns OFF

What i need to change in the code above turn this button on (lamp) so that the layer gets visible in the DetailPageView ?

Thanks in advanced for any Help.

1 Like

Ok Its not the

PageViewPortID = PageView.ActiveViewportID

its

PageViewDetail = PageView.GetDetailViews()
PageViewDetailID = PageViewDetail[0].Id

and later i must call

LayerObj.SetPerViewportVisible(PageViewDetailID,True)
1 Like