Copy link to clipboard
Copied
Hi all,
I was looking into an updated "Layer Comps to Files" when i found How to export multiple layer comps on multiple artboards, it showed a link to an upgraded version which could also do Layercomps on Artboards to files. However, i did like how it executed so i changed some items. I also added new functions, which for me as graphic design make more sense.
Ive been working quite extensively on this script and updated it to 2 variants now. I also got transparencies working for PNG and also added it to TIFF. I also added options for PSD to save layers as well. But also add options to convert to sRGB. This conversion for me is very important, its kind of basic workflow these days, so wonder why this is not implemented as default. I guess because the "layer comps to files" and "artboards to files" are quite old and not looked after anymore.
But i did some minor upgrading as i showed earlier. I took the base from the script linked earlier in the post which can do "layer comps from artboards to files". But i wasnt happy how it always added descriptions, index # and comments. So i made every naming optional. But i also added the option to do a single artboard or choose a layer comp from a menu. Normally you need to select one or multiple. Now you can select just one of you forgot that.
You can find my altered version here;
Photoshop-Scripts
Both scripts can also run without artboards or without layer comps or both. If no artboards are present or no layer comps are selected the options will no be grayed out or be invisible. Thats much better behavior than the original "Layer Comps to FIles".
Layer Comps & Artboard To Files_v6
This one is basically the same as v7 but without the option to choose layer comps. This one works the same as basic "Layer Comps to Files". So it either exports all layer comps when none are selected or only does selected ones.
Layer Comps & Artboard To Files_v7
This has an optional function of picking Layer Comps from the dialog menu. This makes allows the user to keep going even when the wrong layer comp was selected.
Copy link to clipboard
Copied
Thank you for sharing!
Copy link to clipboard
Copied
Ive just got a new version as well. Ive added "trim image" option, also quite handy 🙂
Im currently finding a proper way to clean the files when its saves layered files like the tff and psd version can do.
I got a couple scripts which do this, so need to find the cleanest and fastest method. I guess delete layer comps when document is duplicated and then run "Delete hidden layers" is best here.
Copy link to clipboard
Copied
Does anyone know how to run the command "Deselect Layers" from select menu using script? Ive been search for 2 hours orso and all i find are loop going over all layers. We can use commanda like trim from the image menu. But this simple deselect command is not in the scripting reference or any guide ive found.
Ive also tried using the ScriptListener and record that action and make a function. Somehow it doesnt seem to work when i use it with other functions?
//from scriptlistener plugin
var idselectNoLayers = stringIDToTypeID( "selectNoLayers" );
var desc7 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref3 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idTrgt = charIDToTypeID( "Trgt" );
ref3.putEnumerated( idLyr, idOrdn, idTrgt );
desc7.putReference( idnull, ref3 );
executeAction( idselectNoLayers, desc7, DialogModes.NO );
I would also like the run the command "Delete Hidden Layers"
Copy link to clipboard
Copied
I have 2 different methods here:
// Deselect All Layers
// forums.adobe.com/message/5204655#5204655 - Michael L Hale
app.runMenuItem(stringIDToTypeID('selectNoLayers'));
// Or...
// Deselect All Layers (AM Code Through Clean SL)
selectNoLayers();
function selectNoLayers() {
var c2t = function (s) {
return app.charIDToTypeID(s);
};
var s2t = function (s) {
return app.stringIDToTypeID(s);
};
var descriptor = new ActionDescriptor();
var reference = new ActionReference();
reference.putEnumerated( s2t( "layer" ), s2t( "ordinal" ), s2t( "targetEnum" ));
descriptor.putReference( c2t( "null" ), reference );
executeAction( s2t( "selectNoLayers" ), descriptor, DialogModes.NO );
}
All I can offer for delete hidden layers is:
var idDlt = charIDToTypeID( "Dlt " );
var desc456 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref56 = new ActionReference();
var idLyr = charIDToTypeID( "Lyr " );
var idOrdn = charIDToTypeID( "Ordn" );
var idhidden = stringIDToTypeID( "hidden" );
ref56.putEnumerated( idLyr, idOrdn, idhidden );
desc456.putReference( idnull, ref56 );
executeAction( idDlt, desc456, DialogModes.NO );
or
delete2();
function delete2() {
var c2t = function (s) {
return app.charIDToTypeID(s);
};
var s2t = function (s) {
return app.stringIDToTypeID(s);
};
var descriptor = new ActionDescriptor();
var reference = new ActionReference();
reference.putEnumerated( s2t( "layer" ), s2t( "ordinal" ), s2t( "hidden" ));
descriptor.putReference( c2t( "null" ), reference );
executeAction( s2t( "delete" ), descriptor, DialogModes.NO );
}
Copy link to clipboard
Copied
Col thanks for all the suggestions @stepehen!
I got some working code myself from other scripts. But weird thing in this specific file i have my current method just wont work. Ive duplicated a layer, so its content and name is the same. So i my loop checking if something is visible seems to got corrupt, even though i loop from bottom to top (reverse).
I now even trying by using layerID, see of that works properly. Ill try looking at your suggestions. That one showing the menu command looks already a timesaver. So much cleaner and also just 1 line of code vs 10 orso to do all kinds of loops and such.
Ill post my updated script link here today. Perhaps if anyone can take a look and have a eureka moment :). My issue is when saving rhe layered files after i apply a layer comp seems to be messing up layer visibility. Even though i know that layer is visible, when i run the delete loop, somehow that layers i now visible again?!?!
Just found this great looking tool. You can make dialog windows in a browser. Its allowing you to design the dialog window using an interface. I wont allow you to import old scripts, so you need to rebuild them. But it so cool!
You can export the code and reimport it you need to make adjustments. Keep in mind that the top parts needs to be kept somewhere. Its the json code needed for this online app.
ScriptUI Dialog Builder
Copy link to clipboard
Copied
Copy link to clipboard
Copied
This things is a breeze to work with. Also code looks way cleaner. Als shows me All those are variables declared at the beginning of scripts isn't really necessary. It's just clutter!
Copy link to clipboard
Copied
Adobe, please improve Artboards and Layer Comps to be better integrated. Layer Comps have layer members regardless of which layer groups they are in, and Artboards are basically Canvases, but they are implemented as exclusive layer groups, which is unnecessary. Artboards could be integrated and merged with Layer Comps, by adding the ability of a Layer Comp to remember an artboard (canvas), as well as layer visibility, position, and blending.
This would also allow certain important layers to be shared amongst Artboards, instead of requiring them to be duplicated.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Yes, it's a similar idea, and as a workaround, I'm using the Layer Comps and Artboards to Files script.
Copy link to clipboard
Copied
If you find issues let me know, hope this script helps you