Align Active Layer to Canvas.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment