Copy link to clipboard
Copied
How its possible to select group below currently selected group using javascript? For example i selected group Left and i need to create script which will automatically select group below (Front).
Easy if the group is visible and collapsed, keyboard shortcut of OPT/ALT + [ (which can be recorded into an Action or ScriptingListner can record the code).
However, if expanded, a script would be required as mentioned by @c.pfaffenbichler
Copy link to clipboard
Copied
What is the problem?
Copy link to clipboard
Copied
I complete some other scripts on currently active group (left) and i want to move on a group bellow (front) but i dont know how? P.S. Names of groups are not always same.
Copy link to clipboard
Copied
Do you want to work with DOM code or AM code?
• In the first case you could iterate through the activeLayer’s parent’s layerSets (unless you also want to select the next-lower groups outside the group’s parent).
• In the latter case you could get the itemIndex of the selected Group and then work down from that until you hit the next layerSectionStart after the layerSectionEnd of the selected group.
Copy link to clipboard
Copied
Easy if the group is visible and collapsed, keyboard shortcut of OPT/ALT + [ (which can be recorded into an Action or ScriptingListner can record the code).
However, if expanded, a script would be required as mentioned by @c.pfaffenbichler
Copy link to clipboard
Copied
Thanks, i copy this shortcut from SL and it works ok
var idselect = stringIDToTypeID( "select" );
var desc23 = new ActionDescriptor();
var idnull = stringIDToTypeID( "null" );
var ref18 = new ActionReference();
var idlayer = stringIDToTypeID( "layer" );
var idordinal = stringIDToTypeID( "ordinal" );
var idbackwardEnum = stringIDToTypeID( "backwardEnum" );
ref18.putEnumerated( idlayer, idordinal, idbackwardEnum );
desc23.putReference( idnull, ref18 );
var idmakeVisible = stringIDToTypeID( "makeVisible" );
desc23.putBoolean( idmakeVisible, false );
var idlayerID = stringIDToTypeID( "layerID" );
var list13 = new ActionList();
list13.putInteger( 553 );
desc23.putList( idlayerID, list13 );
executeAction( idselect, desc23, DialogModes.NO );
Copy link to clipboard
Copied
@milevic – fantastic, that is how one starts! The following steps are realising that this can be put into a function and swapping out hard-coded values for variables... Then you'll have a single function that can use a parameter to select either forwards or backwards. I only mention this as it took me a little while before this became obvious (as I am self-taught with no formal JS or programming background).
By itself, this will have problems with an expanded group with child content or non-visible layers. But as long as the groups are collapsed and visible, there shouldn't be any issues.
Copy link to clipboard
Copied