PDA

View Full Version : Query Layer Names


DustinBrown
04-12-2012, 07: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.

PiXeL_MoNKeY
04-12-2012, 08: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

DustinBrown
04-12-2012, 09: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!

LoneRobot
04-12-2012, 09:45 PM
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 (http://lonerobot.net/?p=1239) . 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.

DustinBrown
04-12-2012, 10:02 PM
Cool, thanks for the link, Pete!

CGTalk Moderation
04-12-2012, 10: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.