Currently I'm working on a script that iterates through all the points in a path and assigns a number value of the current point, and then returns the coordinates of that point. No matter how I structure the scope of the functions I'm not getting the current anchor points coordinates, just the final value. Everything else behaves as expected.. I've read every article I can on closures, but any attempt to make a anonymous function returns the code itself, not a value. I'm rather perplexed and guessing I'm missing something about the architecture of .anchor and how it assigns and returns values. Could someone help me get the correct .anchor coordinates to go with the correct point?
i=0; | |
j=0; | |
var currentPath = app.activeDocument.pathItems.getByName("path"); | |
currentPath.select() | |
var totalPoints = currentPath.subPathItems[0].pathPoints.length; | |
var currentX = currentPath.subPathItems[0].pathPoints[i].anchor[0]; | |
var currentY = currentPath.subPathItems[0].pathPoints[i].anchor[1]; | |
currentPoint = Array(currentX, currentY) | |
//Point Loop | |
for(i=0, j=0; i <= totalPoints; i++, j++){ | |
fileOut.write("\n Point "+i+ "of " +totalPoints+ "Coords: "+currentPoint+ "\n") | |
}; | |
currentX, currentY and currentPoint are just new attempts to pass the values on. I'm not wedded to any of this script in particular, just trying to wrap my head around how .js functions in these situations. I'm using fileOut.write as a log generator, but will eventually use returns once I get over this problem.
Thanks in advance!