The price is a bottle of red wine don't go overboard a $15 bottle will do.
// enable double-clicking from Mac Finder or Windows Explorer
#target photoshop // this command only works in Photoshop CS2 and higher
// bring application forward for double-click events
app.bringToFront();
// Save the current preferences
var startRulerUnits = app.preferences.rulerUnits;
// Set Photoshop to use pixels
app.preferences.rulerUnits = Units.PIXELS;
var thePath = selectedPath();
if (thePath == undefined) {
alert("No Path Selected");
}
else {
var myPathInfo = extractSubPathInfo(thePath);
var pathPoints = "Path Points\n"
for(var k=0;k<myPathInfo.length;k++){
pathPoints = pathPoints + "Path" + (k+1) + "\n";
for(var j=0;j<myPathInfo.entireSubPath.length;j++){
pathPoints = pathPoints + "X " + myPathInfo.entireSubPath.anchor[0] + " Y " + myPathInfo.entireSubPath.anchor[1] +"\n";
MarkX(myPathInfo.entireSubPath.anchor[0]);
MarkY(myPathInfo.entireSubPath.anchor[1]);
}
}
alert(pathPoints);
}
////// determine selected path //////
function selectedPath () {
try {
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Path"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var desc = executeActionGet(ref);
var theName = desc.getString(charIDToTypeID("PthN"));
return app.activeDocument.pathItems.getByName(theName)
}
catch (e) {
return undefined
}
};
// Return the app preferences
app.preferences.rulerUnits = startRulerUnits;
////// michael l hale’s code //////
function extractSubPathInfo(pathObj){
var pathArray = new Array();// each element can be used as the second arugment in pathItems.add ie doc.pathItems.add("myPath1", [pathArray[0]]);
var pl = pathObj.subPathItems.length;
for(var s=0;s<pl;s++){
var pArray = new Array();
for(var i=0;i<pathObj.subPathItems.pathPoints.length;i++){
pArray = new PathPointInfo;
pArray.kind = pathObj.subPathItems.pathPoints.kind;
pArray.anchor = pathObj.subPathItems.pathPoints.anchor;
//alert("Anchor " + pathObj.subPathItems.pathPoints.anchor );
pArray.leftDirection = pathObj.subPathItems.pathPoints.leftDirection;
pArray.rightDirection = pathObj.subPathItems.pathPoints.rightDirection;
};
pathArray[pathArray.length] = new Array();
pathArray[pathArray.length - 1] = new SubPathInfo();
pathArray[pathArray.length - 1].operation = pathObj.subPathItems.operation;
pathArray[pathArray.length - 1].closed = pathObj.subPathItems.closed;
pathArray[pathArray.length - 1].entireSubPath = pArray;
};
return pathArray;
};
function MarkX(x) {
// =======================================================
var idMk = charIDToTypeID( "Mk " );
var desc61 = new ActionDescriptor();
var idNw = charIDToTypeID( "Nw " );
var desc62 = new ActionDescriptor();
var idPstn = charIDToTypeID( "Pstn" );
var idPxl = charIDToTypeID( "#Pxl" );
desc62.putUnitDouble( idPstn, idPxl, x);
var idOrnt = charIDToTypeID( "Ornt" );
var idOrnt = charIDToTypeID( "Ornt" );
var idVrtc = charIDToTypeID( "Vrtc" );
desc62.putEnumerated( idOrnt, idOrnt, idVrtc );
var idGd = charIDToTypeID( "Gd " );
desc61.putObject( idNw, idGd, desc62 );
executeAction( idMk, desc61, DialogModes.NO );
}
function MarkY(y) {
// =======================================================
var idMk = charIDToTypeID( "Mk " );
var desc63 = new ActionDescriptor();
var idNw = charIDToTypeID( "Nw " );
var desc64 = new ActionDescriptor();
var idPstn = charIDToTypeID( "Pstn" );
var idPxl = charIDToTypeID( "#Pxl" );
desc64.putUnitDouble( idPstn, idPxl, y );
var idOrnt = charIDToTypeID( "Ornt" );
var idOrnt = charIDToTypeID( "Ornt" );
var idHrzn = charIDToTypeID( "Hrzn" );
desc64.putEnumerated( idOrnt, idOrnt, idHrzn );
var idGd = charIDToTypeID( "Gd " );
desc63.putObject( idNw, idGd, desc64 );
executeAction( idMk, desc63, DialogModes.NO );
}