I can't help with Applescript( or even know if it is possible to do this with Applescript alone ). And to my knowledge you can't script things in dialogs like load or save curve directly. But here is code in javascript that will load and save the settings.
First the easy part, setting an adjustment layer from a file.
function loadCurves( file ) {
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID( "AdjL" ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
desc.putReference( charIDToTypeID( "null" ), ref );
var desc1 = new ActionDescriptor();
desc1.putPath( charIDToTypeID( "Usng" ), new File( file ) );
desc.putObject( charIDToTypeID( "T " ), charIDToTypeID( "Crvs" ), desc1 );
executeAction( charIDToTypeID( "setd" ), desc, DialogModes.NO );
};
The code to write the .acv file from an adjustment layer is bit more involved and doesn't work with all color modes
// Works with RGB or CMYK images.
// Does not work at all with greyscale, or indexColor
// Does not work correctly with Lab
File.prototype.writeByte = function(b) {
this.write(String.fromCharCode(b));
};
File.prototype.writeShort = function(ET,s) {
var self = this;
if(ET == "BE"){
self.writeByte(s & 0xFF);
self.writeByte((s >> 8) & 0xFF);
}else{
self.writeByte((s >> 8) & 0xFF);
self.writeByte(s & 0xFF);
}
return self;
};
function convertBCD( num ){
var res = new Array;
if(num > 16 ){
res.unshift(1);
num = num - 16;
}else{
res.unshift(0);
}
if(num > 8 ){
res.unshift(1);
num = num - 8;
}else{
res.unshift(0);
}
if(num > 4 ){
res.unshift(1);
num = num - 4;
}else{
res.unshift(0);
}
if(num > 2 ){
res.unshift(1);
num = num - 2;
}else{
res.unshift(0);
}
if(num == 1 ){
res.unshift(1);
}else{
res.unshift(0);
}
return res;
};
function getCurve( numberOfPoints ){
this.getPoints = function(){
this.tempArray = new Array;
this.tempArray.push( rawDesc.charCodeAt( pointer ) );
pointer = pointer + 2;// set pointer to next point
this.tempArray.push( rawDesc.charCodeAt( pointer ) );
return this.tempArray;
}
this.pointsArray = new Array;
for( var i = 0; i < numberOfPoints; i++ ){
pointer = pointer + 2;// next point
this.pointsArray.push( this.getPoints() );
}
pointer = pointer + 2;// next curve
return this.pointsArray;
};
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID( 'Lyr ' ), charIDToTypeID( 'Ordn' ), charIDToTypeID( 'Trgt' ) );
var rawDesc = executeActionGet( ref ).getList( stringIDToTypeID( 'adjustment' ) ).getObjectValue( 0 ).getData( stringIDToTypeID( 'legacyContentData' ) );
var pointer = 2;// used to read rawData similar to reading a file
var flag = rawDesc.charCodeAt( pointer );// char at offset 2 always == 1 so use to validate data
if( flag != 1 ) forceError;// unknown problem with rawData
pointer = 6;// update pointer to BCD byte
var bcd = rawDesc.charCodeAt( pointer );
if( bcd < 0 || bcd > 31 ) forceError;// check for valid value
if( bcd == 0 ) forceError;// an empty adjustment - no curves to process
var bcdArray = convertBCD( bcd );
var numberOfCurves = bcdArray.toString().match(/(1)/g).length;
var curvesArray = new Array;
pointer = 8;// set pointer to start of curve data
for(var i = 0; i < numberOfCurves; i++ ){
var numberOfPoints = rawDesc.charCodeAt( pointer );
curvesArray.push( getCurve( numberOfPoints ) );
}
// now need to map rawData curves in curvesArray to known channel curves
var acvArray = new Array;
if( bcdArray[0] == 1 ) {
acvArray.push( curvesArray.shift() );
} else {
acvArray.push( [ [0,0],[255,255] ] );
}
if( bcdArray[1] == 1 ) {
acvArray.push( curvesArray.shift() );
} else {
acvArray.push( [ [0,0],[255,255] ] );
}
if( bcdArray[2] == 1 ) {
acvArray.push( curvesArray.shift() );
} else {
acvArray.push( [ [0,0],[255,255] ] );
}
if( bcdArray[3] == 1 ) {
acvArray.push( curvesArray.shift() );
} else {
acvArray.push( [ [0,0],[255,255] ] );
}
if( bcdArray[4] == 1 ) {
acvArray.push( curvesArray.shift() );
} else {
acvArray.push( [ [0,0],[255,255] ] );
}
var myACV = new File('~/desktop/myCurve.acv');
myACV.open('w');
myACV.writeShort( 'LE','4' );// acv header
myACV.writeShort( 'LE','5' );// acv header
for( var i = 0; i< 5; i++ ) {
var numberOfPoints = acvArray.length;
myACV.writeShort( 'LE', numberOfPoints.toString() );
for( var p = 0; p < numberOfPoints; p++ ){
myACV.writeShort( 'LE', acvArray
[0].toString() );
myACV.writeShort( 'LE', acvArray
[1].toString() );
}
}
myACV.close();
I wrote this a while back. It might be possible to just write the acv header then add the raw data from the descriptor to work with other modes.
Also neither checks that the selected layer is a curves adjustment layer and will fail if it is not.