Layer Set Groups

Upload photoshop scripts, download photoshop scripts, discussion and support of photoshop scripts

Moderator: PS-Moderators

Layer Set Groups

Postby Paul MR » Tue Feb 21, 2012 10:17 pm

Photoshop CS4 or better

This script will allow you to save selected layers so that they may be recalled/selected
You can have as many sets as you like.
Removal of set is supported.
Layers can be moved and they will still be selected if part of a set.
All the information is held within the documents metadata.
Attachments
Layer Set Groups.zip
Layer Set Groups
(2.22 KiB) Downloaded 396 times
Paul MR
 
Posts: 1472
Joined: Wed Oct 18, 2006 2:44 pm
Location: Bradford,UK

Re: Layer Set Groups

Postby Jeremy Knudsen » Mon Feb 27, 2012 7:33 pm

Interesting usage of per layer XMP metadata. I did find a minor bug when you define a Preset that contains the Background layer having been selected. When using the Preset it doesn't set the selection of the background layer (an alert pops up saying the layer is not found--at least the background layer exception is handled).
Jeremy Knudsen
 
Posts: 33
Joined: Mon Nov 08, 2010 4:31 pm

Re: Layer Set Groups

Postby Paul MR » Mon Feb 27, 2012 9:05 pm

Nice catch, to fix that problem change line 148

from:
Code: Select all
if(result != true){

to
Code: Select all
if(result > 0){
Paul MR
 
Posts: 1472
Joined: Wed Oct 18, 2006 2:44 pm
Location: Bradford,UK

Re: Layer Set Groups

Postby Jeremy Knudsen » Tue Aug 21, 2012 9:58 pm

Hi Paul,

I think I found one more bug in your code.

If the layer in the layer set is not found, instead of returning true...
Code: Select all
function getLayerItemIndexByLayerID(id) {
    var ref = new ActionReference();
    ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID( "ItmI" ));
    ref.putIdentifier( charIDToTypeID( "Lyr " ), id );
   try{
    return executeActionGet(ref).getInteger(charIDToTypeID( "ItmI" ));
   }catch(e){return true;}
};


...I think you want to return false:

Code: Select all
function getLayerItemIndexByLayerID(id) {
    var ref = new ActionReference();
    ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID( "ItmI" ));
    ref.putIdentifier( charIDToTypeID( "Lyr " ), id );
   try{
    return executeActionGet(ref).getInteger(charIDToTypeID( "ItmI" ));
   }catch(e){return false;}
};


This way, the selLayer method that calls the method above will display the 'Layer does not exist' message:
Code: Select all
function selLayer(layerID,add) {
var result = getLayerItemIndexByLayerID(layerID);
if (result > 0) {
    try{
        activeDocument.backgroundLayer;
        var bkGround = 1;
    } catch(e) {var bkGround = 0;}
        selectLayerByIndex(result - bkGround ,add);
   } else {
        alert("Layer does not exist");      
    }
};
Jeremy Knudsen
 
Posts: 33
Joined: Mon Nov 08, 2010 4:31 pm


Return to Photoshop Scripts

Who is online

Users browsing this forum: No registered users and 1 guest