Revision: 67865
Updated Code
at October 31, 2014 07:29 by TheRabbitFlash
Updated Code
/* 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 ); }
Revision: 67864
Updated Code
at October 31, 2014 07:28 by TheRabbitFlash
Updated Code
/* 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, press OK 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 ); }
Revision: 67863
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 31, 2014 07:14 by TheRabbitFlash
Initial Code
/* 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) 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, press OK 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 ); }
Initial URL
Initial Description
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;
Initial Title
Copy current photoshop selection bounds to x,y,width,height to As3 code
Initial Tags
copy
Initial Language
ActionScript 3