Hey everyone,
I have this script which saves out layersets in a document as tif files. When I run it on my computer it works fine, but when another artist runs it, the tif save options dialog pops up every time (which kind of defeats the whole purpose). Can anyone tell me how to universally suppress that options dialog in the script?
Thanks
Code: Select all#target photoshop
//===============================================Check to see if there are any open documents================================================
if (documents.length == 0) {
alert ("There are no documents open. Please open a PSD in order to run this script.");
}
else {
//===============================================Check to see if there are any visible layerSets================================================
var visLayerSets = 0;
for (i = 0; i < activeDocument.layerSets.length; i++) {
if(activeDocument.layerSets.visible == true)
visLayerSets++;
}
if (visLayerSets == 0) {
alert ("You have no visible layerSets. Please unhide at least one, then run the script again.");
}
else {
//===========================================================Tif parameters============================================================
var tifParams = new TiffSaveOptions()
tifParams.layers = false;
//===========================================================Save Tifs================================================================
var origDoc = activeDocument;
var activePath = activeDocument.path;
var shortName = app.activeDocument.name.replace(/\.[^\.]+$/, "");
origDoc.duplicate (name = "Duplicated");
var tempDoc = activeDocument;
tempDoc.resizeImage (null, UnitValue (1024,"px"), null, ResampleMethod.BICUBIC);
var uvsVis = tempDoc.artLayers.getByName ("Uvs").visible;
var settings = new Array ();
//hides the uvs to keep them from being in the texture
function hideUvs () {
tempDoc.activeLayer = tempDoc.artLayers.getByName ("Uvs");
activeDocument.activeLayer.visible = false;
}
hideUvs ();
//exports the png files
function exportTifs () {
for (i = 0; i < tempDoc.layers.length; i++) {
var currentLayer = tempDoc.layers ;
var layerVis = currentLayer.visible;
var curLayer = currentLayer.name;
if (layerVis == true) {
var saveFile = File (activePath + "/" + shortName + "_" + curLayer + ".tif");
activeDocument.saveAs (saveFile, tifParams, true, Extension.LOWERCASE);
var layerFinished = tempDoc.activeLayer.name;
}
currentLayer.visible = false;
}
}
exportTifs ();
tempDoc.close (SaveOptions.DONOTSAVECHANGES);
}
}
Suppress tiff options dialog
-
Mike Hale
Suppress tiff options dialog
From a quick skim of your code, the only reason I can think of for the dialog showing would be the user has dialogmodes set to all( the default is error ).
You could try adding two lines at the top of your script to store the users current dialogmodes and set it to no. Then add another line at the bottom to restore to user's original setting.
You could try adding two lines at the top of your script to store the users current dialogmodes and set it to no. Then add another line at the bottom to restore to user's original setting.
-
applezap
Suppress tiff options dialog
If the problem continues, I'll give that a try. Thanks Mike.