Created
August 3, 2014 21:47
-
-
Save nvieirafelipe/f1ed0228d28862a113c0 to your computer and use it in GitHub Desktop.
Get coords from photoshop selection
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
// Make the selection you want to get the coordinates from | |
// Go to File > Scripts > Browse... > coordsFromSelection.jsx | |
var startRulerUnits = app.preferences.rulerUnits | |
var startTypeUnits = app.preferences.typeUnits | |
app.preferences.rulerUnits = Units.PIXELS | |
app.preferences.typeUnits = TypeUnits.PIXELS | |
var doc = app.activeDocument; | |
doc.selection.makeWorkPath(0); | |
var wPath = doc.pathItems['Work Path']; | |
var stride = 1; | |
var coords_array = new Array(); | |
for (var i=0; i<wPath.subPathItems[0].pathPoints.length; i++) { | |
if (i % stride === 0) { | |
coords_array.push(wPath.subPathItems[0].pathPoints[i].anchor); | |
} | |
} | |
var coords = new File("/tmp/coords.txt"); | |
coords.open("w"); | |
coords.writeln(coords_array.join(",")); | |
coords.close(); | |
coords.execute() | |
wPath.remove(); | |
app.preferences.rulerUnits = startRulerUnits; | |
app.preferences.typeUnits = startTypeUnits; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment