Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@MarshySwamp
Last active June 26, 2022 21:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MarshySwamp/df372e342ac87854ffe08e79cbdbcbb5 to your computer and use it in GitHub Desktop.
Save MarshySwamp/df372e342ac87854ffe08e79cbdbcbb5 to your computer and use it in GitHub Desktop.
Align Active Layer to Select All.jsx
// Align Active Layer to Select All.jsx
// Change as required
align2SelectAll('AdCH');
align2SelectAll('AdCV');
function align2SelectAll(method) {
//www.ps-scripts.com/viewtopic.php?f=66&t=7036&p=35273&hilit=align+layer#p35273
/*
//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
*/
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();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment