How can I record layer alignment baseline?

Contributor ,
Mar 20, 2022 Mar 20, 2022

Copy link to clipboard

Copied

I'm trying to record an Action that's aligning a layer. However, no step is recorded when I change the alignment baseline from "layer" to "canvas". So, the recorded Action will be very brittle, depending on the future current value of this application setting.

 

Is there a way to persist the layer alignment baseline setting?

 

How can I record canvas alignment.gif

 

I couldn't find a corresponding ExtendScript property for this setting, too. So I cannot create a corresponding script, either. Which property would I need to set in JavaScript?

 

Your answers are appreciated.

TOPICS
Actions and scripting

Views

155

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

correct answers 1 Correct answer

Adobe Community Professional , Mar 20, 2022 Mar 20, 2022
What if you first did a Select > All?

Likes

Translate

Translate
Adobe Community Professional ,
Mar 20, 2022 Mar 20, 2022

Copy link to clipboard

Copied

What if you first did a Select > All?

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
Contributor ,
Mar 21, 2022 Mar 21, 2022

Copy link to clipboard

Copied

Excellent answer! Thank you 🙂

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
Adobe Community Professional ,
Mar 21, 2022 Mar 21, 2022

Copy link to clipboard

Copied

Thank you. Happy to help.

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
Adobe Community Professional ,
Mar 20, 2022 Mar 20, 2022

Copy link to clipboard

Copied

Just to add to @Michael Bullo suggestion, record Select > All as action step, selection must be active when playing action, action will align to selection not to canvas.

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
Adobe Community Professional ,
Mar 21, 2022 Mar 21, 2022

Copy link to clipboard

Copied

Here is align to canvas via scripting listener:

 

https://gist.github.com/MarshySwamp/618a08fd04c4f3ed0027f6926b6d9d62

 

// Align Active Layer to Canvas.jsx

/* 
ADSLefts      =   Align Left
ADSRights     =   Align Right
ADSCentersH   =   Align Centre Horizontal
ADSTops       =   Align Top
ADSBottoms    =   Align Bottom
ADSCentersV   =   Align Centre Vertical
null          =   insert "null" to quickly disable one of the two alignment options
*/

alignToCanvas(true, "ADSLefts");
alignToCanvas(true, "ADSTops");

function alignToCanvas(alignToCanvas, alignValue) {
	var s2t = function (s) {
		return app.stringIDToTypeID(s);
	};
	var descriptor = new ActionDescriptor();
	var reference = new ActionReference();
	reference.putEnumerated( s2t( "layer" ), s2t( "ordinal" ), s2t( "targetEnum" ));
	descriptor.putReference( s2t( "null" ), reference );
	descriptor.putEnumerated( s2t( "using" ), s2t( "alignDistributeSelector" ), s2t( alignValue ));
	descriptor.putBoolean( s2t( "alignToCanvas" ), alignToCanvas );
	executeAction( s2t( "align" ), 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
Adobe Community Professional ,
Mar 21, 2022 Mar 21, 2022

Copy link to clipboard

Copied

And align to select all:

 

https://gist.github.com/MarshySwamp/df372e342ac87854ffe08e79cbdbcbb5

 

// Align Active Layer to Select All.jsx

/* 
//macscripter.net/viewtopic.php?id=38890
AdLf = Align Left
AdRg = Align Right
AdCH = Align Centre Horizontal
AdTp = Align Top
AdBt = Align Bottom
AdCV = Align Centre Vertical
*/

//www.ps-scripts.com/viewtopic.php?f=66&t=7036&p=35273&hilit=align+layer#p35273

align2SelectAll('AdCH'); align2SelectAll('AdCV'); //Change as required

function align2SelectAll(method) {

   app.activeDocument.selection.selectAll();

   var desc = new ActionDescriptor();
   var ref = new ActionReference();
   ref.putEnumerated(charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));
   desc.putReference(charIDToTypeID("null"), ref);
   desc.putEnumerated(charIDToTypeID("Usng"), charIDToTypeID("ADSt"), charIDToTypeID(method));
   try {
      executeAction(charIDToTypeID("Algn"), desc, DialogModes.NO);
   } catch (e) { }

   app.activeDocument.selection.deselect();

}

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
Contributor ,
Mar 21, 2022 Mar 21, 2022

Copy link to clipboard

Copied

Very nice! 👍

 

Thanks for sharing!

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
Adobe Community Professional ,
Mar 21, 2022 Mar 21, 2022

Copy link to clipboard

Copied

I was curious, so I recorded two actions, one aligning to canvas and one aligning to selection. I converted each to a script using xtools.

 

The only notable difference in the code is:

 

desc1.putBoolean(sTID("alignToCanvas"), true);

 

vs.

 

desc1.putBoolean(sTID("alignToCanvas"), false);

 

 

However, when the action is played, both versions will error and fail if there is no selection before running the action. Align to canvas shouldn't require a selection, as the scripts posted above demonstrate. Therefore I can only conclude that this is a long-standing bug in the action playback, as the boolean for canvas appears to be recorded into the action, even if not visible in the action panel interface.

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
LEGEND ,
Mar 21, 2022 Mar 21, 2022

Copy link to clipboard

Copied

Will you report a bug?

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
Adobe Community Professional ,
Mar 22, 2022 Mar 22, 2022

Copy link to clipboard

Copied

LATEST

Done:

 

https://community.adobe.com/t5/photoshop-ecosystem-bugs/align-to-canvas-ignored-in-action-playback/i...

 

Please add your (up)vote if you can reproduce this issue.

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