Quantcast
Channel: Adobe Community : Unanswered Discussions - Photoshop
Viewing all articles
Browse latest Browse all 74445

selection coordinates output

$
0
0

Good day to all,

 

First of all, I am so new in programming.

I just learn about a week (Java Language).

 

I already have a code that shows the coordinates of selected area.

But the output in the text file is x,y,x,y,x,y...

I want the output to be x,x,x... and y,y,y... in new line.

 

Example:

 

In the code, the output is:

 

578,337,529,488,512,526,478,512,486,464,484,464,480,475,477,475,479,45 8,477,458,472,462,472,458,476,442,484,420,519,363,528,355,554,334

 

What I want is:

 

578,529,512,489,478,486,484,480,477,479,477,472,472,476,484,519,528,55 4

337,488,526,517,512,464,464,475,475,458,458,462,458,442,420,363,355,33 4

 

I mean the x coordinates are on first line and y are on the second line.

 

Here is my code:

 

#target Photoshop

 

 

 

var data=mapa_seleccion(activeDocument,data)

 

 

 

function mapa_seleccion(doc,out){

      var hs = doc.historyStates;

      preferences.rulerUnits = Units.PIXELS;

      doc.selection.makeWorkPath(1);

      var p = doc.pathItems["Work Path"];

      var a = new Array();

      var t = 0;

      var l = p.subPathItems.length;

      for ( k = 0; k < l; k++) {

           var n = p.subPathItems[k].pathPoints.length;

           a[k] = new Array (n);

           for ( i = 0; i < n; i++){

                a[k][i] = new Array();

                a[k][i]=p.subPathItems[k].pathPoints[i].anchor;

       

                }

           }

      var t = 0;

      for ( k = 0; k < l; k++) {

           var n = a[k].length;

           var s = 0;

           for ( i = 0; i < n; i++){

                var j = (i+1)%n;

                s+=(a[k][i][0]*a[k][j][1]);

                s-=(a[k][i][1]*a[k][j][0]);

                }

           s/=2;

           t+=s;

 

 

 

           }

 

 

 

      doc.activeHistoryState = hs[hs.length-2];

      out=new Array()

      out.mapa=a

      out.area=parseFloat(t/doc.resolution/doc.resolution*2.54*2.54).toFixe d(2) //conv ierte a cm2

 

 

 

      return out

      }

 

 

 

alert(data.mapa[0]);

 

 

 

//data.mapa[0];

if ($.os.search(/windows/i) != -1)

    fileLineFeed = "windows";

else

    fileLineFeed = "macintosh";

  

var fileName = app.activeDocument.name

 

 

 

var fileOut = new File('~/Desktop/coords.txt');

fileOut.linefeed = fileLineFeed;

fileOut.open("w", "TEXT", "");

fileOut.writeln(data.mapa[0]);

fileOut.close();

 

Thanks to muyshangai for the codes.

 

 

And thank you guys in advance


Viewing all articles
Browse latest Browse all 74445

Trending Articles