Quantcast
Channel: Adobe Community: Message List
Viewing all articles
Browse latest Browse all 135144

Re: Lock layer OR other layer (if name is different)

$
0
0

you'd be fine with just doing this (below) -- since your layers' names are already known to you.  The function puts the get-by-names into a try{}catch{} so that the script won't error-out when a name isn't found:

 

function test(){    function tryLockLayer(name){        try{            lrs.getByName(name).locked = true;        } catch(e) {            return;        }    };      var doc=app.activeDocument;    var lrs = doc.layers;    tryLockLayer("Artwork");    tryLockLayer("Graphics");    tryLockLayer("Info");  
}


test();


also if the layers other than Info are ones you want to lock, you can just loop and lock layers whose names are not "info"


Viewing all articles
Browse latest Browse all 135144

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>