• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

Move layerset one position up, scripting

Contributor ,
Nov 05, 2022 Nov 05, 2022

Copy link to clipboard

Copied

It is possible to move the selected layerset, one position up ?

From

 

To 

TOPICS
Actions and scripting

Views

45

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 05, 2022 Nov 05, 2022

Copy link to clipboard

Copied

@siomosp – Here is the scripted version of the Layer/Arrange/Bring Forward command CTRL/CMD + ]

 

move("next"); // "next" or "previous" or "front" or "back"

function move(pos) {
	function s2t(s) {
		return app.stringIDToTypeID(s);
	}
	var descriptor = new ActionDescriptor();
	var reference = new ActionReference();
	var reference2 = new ActionReference();
	reference.putEnumerated( s2t( "layer" ), s2t( "ordinal" ), s2t( "targetEnum" ));
	descriptor.putReference( s2t( "null" ), reference );
	reference2.putEnumerated( s2t( "layer" ), s2t( "ordinal" ), s2t( pos ));
	descriptor.putReference( s2t( "to" ), reference2 );
	executeAction( s2t( "move" ), descriptor, DialogModes.NO );
}

 

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 05, 2022 Nov 05, 2022

Copy link to clipboard

Copied

LATEST

😄
I have found an older script. And IMHO the important part of the script was also from @Stephen_A_Marsh 

 

var c2t = function (s) {
    return app.charIDToTypeID(s);
};
var s2t = function (s) {
    return app.stringIDToTypeID(s);
};
if (activeDocument.activeLayer.typename == 'LayerSet' ) {
	var aSet = activeDocument.activeLayer.name;
    alert("Active Layer Set");
    var descriptor = new ActionDescriptor();
	var reference = new ActionReference();
	var reference2 = new ActionReference();
	reference.putEnumerated( s2t( "layer" ), s2t( "ordinal" ), s2t( "targetEnum" ));
	descriptor.putReference( c2t( "null" ), reference );
	reference2.putEnumerated( s2t( "layer" ), s2t( "ordinal" ), s2t( "next" ));
	descriptor.putReference( s2t( "to" ), reference2 );
	executeAction( s2t( "move" ), descriptor, DialogModes.NO );
    } else {
    alert("No active Layer Set");
    }

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines