View Full Version : Query Layer Names

04 April 2012, 06:59 PM
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.

04 April 2012, 07:50 PM
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

04 April 2012, 08:28 PM
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!

04 April 2012, 08:45 PM

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.

04 April 2012, 09:02 PM
Cool, thanks for the link, Pete!

CGTalk Moderation
04 April 2012, 09:02 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.