I have an illustrator file that contains 4 layers with each its own word and 180 more layers. I want to make combinations of the 4 layers with the 180 layers.
I'm currently trying to write the code with the information I found on the internet. I put every layer with the name "Layer" in a new array called fabriks. What I don't know is how to activate the layer "make", "think", "search", "print", and "makerspace" one by one to be exported with the layers in the fabriks array. I created a second array "rooms" to put the 4 words in there.
The code doesn't fully work. It exports the images but some layers overlap each other and sometimes only one layer from the fabriks array is visible but not from the rooms array.
var outpath = "~/Desktop/FABRIK MAKERSPACE";
var doc = app.activeDocument;
var makerspace = app.activeDocument.layers.getByName("Makerspace");
var make = app.activeDocument.layers.getByName("Maakt");
var think = app.activeDocument.layers.getByName("Denkt");
var search = app.activeDocument.layers.getByName("Zoekt");
var print = app.activeDocument.layers.getByName("Print");
var targetLayerName;
var layerName = "Layer";
var fabriks = Array();
var layers = doc.layers;
var rooms = Array();
rooms.push(makerspace);
rooms.push(make);
rooms.push(think);
rooms.push(search);
rooms.push(print);
for (var i = 0; i < layers.length; i++) {
targetLayerName = new String(layers[i].name);
if (targetLayerName == layerName) {
fabriks.push(layers[i]);
}
layers[i].visible = false;
}
var counter = fabriks.length;
for (var i = 0; i < rooms.length; i++) {
var roomsName = String(rooms[i].name);
rooms[i].visible = true;
for (var i = 0; i < fabriks.length; i++) {
fabriks[i].visible = true;
var fname = outpath + "FABRIK_" + roomsName + "_" + counter;
var f = new File(fname + '.png');
var exportOptions = new ExportOptionsPNG8(); // or PNG24
exportOptions.colorCount = 200;
exportOptions.transparency = true;
app.activeDocument.exportFile(f, ExportType.PNG8, exportOptions);
for (var j = 0; j < fabriks[i].length - 1; j++) {
fabriks[i].visible = false;
}
rooms[i].visible = false;
}
counter--;
}
Thank you