Quantcast
Channel: Adobe Community: Message List - Photoshop Scripting
Viewing all articles
Browse latest Browse all 27456

Re: layer group visibility toggle

$
0
0

I have a script that does what you need. Can't remember if I obtained it from here, but I do know that the scripting guys in here are geniuses and can help you out with almost anything. That said, here is the script that you need. All you need to do is replace the three "Insert Layer Name Here" portions with the name of the layer you wish to toggle on/off. Don't thank me, thank whoever wrote it, (most likely someone here)

 

var targetID = getLayerIDByName('Insert Layer Name here');
if(undefined != targetID){    if(getLayerVisibilityByID( targetID ) ){        hideByName('Insert Layer Name here');    }else{        showByName('Insert Layer Name here');    }
}
function getLayerIDByName(name) {    try{    var ref = new ActionReference();    ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID( "LyrI" ));    ref.putName( charIDToTypeID( "Lyr " ), name );    return executeActionGet(ref).getInteger(charIDToTypeID( "LyrI" ));    }catch(e){}
};
function getLayerVisibilityByID( id ) {    var ref = new ActionReference();    ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID( "Vsbl" ));    ref.putIdentifier( charIDToTypeID( "Lyr " ), id );    return executeActionGet(ref).getBoolean(charIDToTypeID( "Vsbl" ));
};
function hideByName(name) {    var desc = new ActionDescriptor();        var list = new ActionList();            var ref = new ActionReference();            ref.putName( charIDToTypeID('Lyr '), name );        list.putReference( ref );    desc.putList( charIDToTypeID('null'), list );    executeAction( charIDToTypeID('Hd  '), desc, DialogModes.NO );
};
function showByName(name) {    var desc = new ActionDescriptor();        var list = new ActionList();            var ref = new ActionReference();            ref.putName( charIDToTypeID('Lyr '), name );        list.putReference( ref );    desc.putList( charIDToTypeID('null'), list );    executeAction( charIDToTypeID('Shw '), desc, DialogModes.NO );
};

 

EDIT- whoops, I just realized this is only for layers, not groups. But hopefully it's a starting point


Viewing all articles
Browse latest Browse all 27456

Trending Articles



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