/ Published in: ActionScript 3
This script allow you copy to the clipboard current layer properties in format:
&selectionBounds.x = &layerx; &selectionBounds.y = &layery; // &selectionBounds.width = &layerwidth; // &selectionBounds.height = &layerheight;
&selectionBounds.x = &layerx; &selectionBounds.y = &layery; // &selectionBounds.width = &layerwidth; // &selectionBounds.height = &layerheight;
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/* How to use: 1) Save this script as SelectionBoundsToAS3.jsx 2) Open Photoshop 3) Select layer in PSD 4) Go to File > Scripts > Browse > Select this file (SelectionBoundsToAS3) 5) Go to AS3 editor and press CTRL+V You can put this script to hotkey: 1) Go to Window > Actions 2) Create new folder in the Actions panel 3) Press Create new action 4) Put name and choice hotkey 5) Than press Record 6) Iterate once "How to use" so action will save script launching parameters 7) In the Actions panel press Stop button Now you can automatically call this script by button :) */ if ( app.documents.length > 0 ) { preferences.rulerUnits = Units.PIXELS; var layerRef = app.activeDocument.selection; var layerName = "selectionBounds"; var x = layerRef.bounds[0].value; var y = layerRef.bounds[1].value; var width = layerRef.bounds[2].value - x; var height = layerRef.bounds[3].value - y; var clp = ""; clp += "\t\t" + layerName + ".x = " + x +";\r"; clp += "\t\t" + layerName + ".y = " + y +";\r"; clp += "\t\t// " + layerName + ".width = " + width +";\r"; clp += "\t\t// " + layerName + ".height = " + height +";\r"; copyTextToClipboard(clp); } else { alert("You must have one opened document at least!"); } function copyTextToClipboard(txt){ const keyTextData = app.charIDToTypeID('TxtD'); const ktextToClipboardStr = app.stringIDToTypeID( "textToClipboard" ); var textStrDesc = new ActionDescriptor(); textStrDesc.putString( keyTextData, txt ); executeAction( ktextToClipboardStr, textStrDesc, DialogModes.NO ); }