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

How can I record layer alignment baseline?

Engaged ,
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

437

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

Community Expert , Mar 20, 2022 Mar 20, 2022

What if you first did a Select > All?

Votes

Translate

Translate
Adobe
Community Expert ,
Mar 20, 2022 Mar 20, 2022

Copy link to clipboard

Copied

What if you first did a Select > All?

Votes

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

Copy link to clipboard

Copied

Excellent answer! Thank you 🙂

Votes

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

Copy link to clipboard

Copied

Thank you. Happy to help.

Votes

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 ,
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.

Votes

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 ,
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) {
	
	app.activeDocument.selection.selectAll();
	
	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 );
	
	app.activeDocument.selection.deselect();
}

 

Votes

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 ,
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();

}

Votes

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

Copy link to clipboard

Copied

Very nice! 👍

 

Thanks for sharing!

Votes

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 ,
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.

Votes

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?

Votes

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 ,
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.

Votes

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