Advertisement
mkonecny

Path to Coordinates

Jun 9th, 2014
1,805
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #target photoshop
  2. var origUnits = app.preferences.rulerUnits;
  3. app.preferences.rulerUnits = Units.PIXELS;
  4.  
  5. var activeDoc = app.activeDocument;
  6. if (typeof activeDoc.path == 'undefined') {
  7.     var myPath='c:';
  8. } else {
  9.     var myPath = app.activeDocument.path;
  10. }
  11. filePath = myPath + '/path_coords.txt';
  12. var f = new File(filePath);
  13. f.open('w');
  14.  
  15. for (i=0;i<activeDoc.pathItems.length;i++) {
  16.     var myPathItem = activeDoc.pathItems[i];
  17.     for (j=0;j<myPathItem.subPathItems.length;j++) {
  18.         var mySubPathItem = myPathItem.subPathItems[j];
  19.         f.writeln(myPathItem.name + ', subpath ' + j);
  20.         var nrPoints = mySubPathItem.pathPoints.length;
  21.         for (k=0;k<nrPoints;k++) {
  22.             var myPoint = mySubPathItem.pathPoints[k];
  23.            
  24.             var myAnchor = String(myPoint.anchor);
  25.             var coords = myAnchor.split(',');
  26.             f.write(Math.round(coords[0]) + ',' + Math.round(coords[1]));
  27.            
  28.             if (k+1!=nrPoints) f.write(',');
  29.         }
  30.         f.writeln();
  31.     }
  32. }
  33.  
  34. f.close('w');
  35. app.preferences.rulerUnits = origUnits;
  36. //alert('Coordinates writen to file ' + filePath);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement