I have a script which loads colors from a .txt file. It loads the colors into the psd file, and inerts them into four different layers, then saves with a filename which is also in the .txt file. It basically works great to do what it was intended to do.
Now, I want to add the functionality to add one more color to the equation, this color will be the layer's Bevel and Emboss effect's "highlight color". Can anyone please help?
Here is the code I have, again it works great, I just want to add one more color to the equation but the syntax is confusing:
#target photoshop
if (app.documents.length > 0) {
var myDocument = app.activeDocument;
var documentName = myDocument.name;
var basename = documentName.match(/(.*)\.[^\.]+$/)[1];
// get path;
try {var documentPath = myDocument.path}
catch (e) {var documentPath = "~/Desktop"};
// psd options, not using this anymore;
psdOpts = new PhotoshopSaveOptions();
psdOpts.embedColorProfile = true;
psdOpts.alphaChannels = false;
psdOpts.layers = true;
psdOpts.spotColors = true;
// jpg options
jpgOptions = new JPEGSaveOptions();
jpgOptions.embedColorProfile = true;
jpgOptions.formatOptions = FormatOptions.STANDARDBASELINE;
jpgOptions.matte = MatteType.NONE;
jpgOptions.quality = 9;
// get file;
if ($.os.search(/windows/i) != -1) {var theFile = File.openDialog ("please select files", "*.txt", false)}
else {var theFile = File.openDialog ("please select files", getFiles, false)};
if (theFile) {
var theText = readPref(theFile);
var theArray = theText.split("\n");
//
try {
var theLayer = myDocument.layers.getByName("colorLayer");
var theOtherLayer = myDocument.layers.getByName("colorLayer2");
var curveOne = myDocument.layers.getByName("TopCurve");
var curveTwo = myDocument.layers.getByName("BottomCurve");
// work through list;
for (var m = 0; m < theArray.length; m++) {
var thisText = theArray[m].split(";");
// alert (thisText.join("\n\n"));
var theName = thisText[0];
editSolidFill (thisText[1], thisText[2], thisText[3], theLayer);
editSolidFill (thisText[1], thisText[2], thisText[3], curveOne);
editSolidFill (thisText[5], thisText[6], thisText[7], theOtherLayer);
editSolidFill (thisText[9], thisText[10], thisText[11], curveTwo);
// save psd;
myDocument.saveAs((new File(documentPath+"/"+basename+"_"+theName+".jpg")),jpgOptions,true);
}
}
catch (e) {};
};
};
////// function to change solid fill layers //////
function editSolidFill (theL, theA, theB, theLayer) {
app.activeDocument.activeLayer = theLayer;
// =======================================================
var idsetd = charIDToTypeID( "setd" );
var desc3 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref2 = new ActionReference();
var idcontentLayer = stringIDToTypeID( "contentLayer" );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref2.putEnumerated( idcontentLayer, idOrdn, idTrgt );
desc3.putReference( idnull, ref2 );
var idT = charIDToTypeID( "T " );
var desc4 = new ActionDescriptor();
var idClr = charIDToTypeID( "Clr " );
var desc5 = new ActionDescriptor();
var idLmnc = charIDToTypeID( "Lmnc" );
desc5.putDouble( idLmnc, theL );
var idA = charIDToTypeID( "A " );
desc5.putDouble( idA, theA );
var idB = charIDToTypeID( "B " );
desc5.putDouble( idB, theB );
var idLbCl = charIDToTypeID( "LbCl" );
desc4.putObject( idClr, idLbCl, desc5 );
var idsolidColorLayer = stringIDToTypeID( "solidColorLayer" );
desc3.putObject( idT, idsolidColorLayer, desc4 );
executeAction( idsetd, desc3, DialogModes.NO );
};
////// read prefs file //////
function readPref (thePath) {
if (File(thePath).exists == true) {
var file = File(thePath);
file.open("r");
file.encoding= 'BINARY';
var theText = new String;
for (var m = 0; m < file.length; m ++) {
theText = theText.concat(file.readch());
};
file.close();
return String(theText)
}
};
////// get psds, tifs and jpgs from files //////
function getFiles (theFile) {
if (theFile.name.match(/\.(txt)$/i)) {
return true
};
};