[Closed] Query Layer Names
I have a little snippet of code that will hide layers by name.
hideCameraLayer=layerManager.getLayerFromName "Cameras"
hideCameraLayer.isHidden = true
I’m not certain how to first test see if that layer exists. If it were a node, I would use
if $.name != undefined do
Or if it were an array I would append nodes into the array then use
if arrayName.count > 0 do
But I don’t know how to do the equivalent of that for layers by name.
getLayerFromName will return undefined if it doesn’t exist. You can collect the layer names using this:
layerNames = for val in 0 to (layermanager.count-1) collect (layermanager.getlayer val).name
-Eric
Ok so since it will return undefined this should work.
hideCameraLayer = layerManager.getLayerFromName "Cameras"
if hideCameraLayer != undefined then hideCameraLayer.isHidden = true
I’ll give that a try. Thanks!
Dustin,
I wrote a layer control script as part of my talk at EUE last year – the write up, including all the source code is here . It shows how you can group things together by using a suffix to control layer visibility. It might be useful to pick apart and use bits for your script.