Copy link to clipboard
Copied
Hello everyone!
Apologies if this has already been asked before, but I have a challenge that has got me hitting a wall:
I have been provided a ton of indesign files (hundereds), each with different layers consisting of different designs. Example Layers: 'Poster Design 1' 'Poster Design 2' 'Poster Design 3' ect ect.
I have also been provided a csv to pair with each indesign file, with lots of different shops + different data merge variables, with a column containing a number based on which design they would like to use.
I understand I could split the data and manually sort this out, however I have so many different files to use, that this could take me weeks.
Is there a script that would handle this? a switch of somesort?
design === 1 ? layer 1 visible true : layer 1 visible false
(apologies for my terrible understanding of javascript)
Thanks in advance, I imagine this is a big ask, so feel free to deal me the 'gonna have to do it manually' blow.
AC
1 Correct answer
The way to do it is to set up the layername field as a non-printing textbox on your merge template, and name that text frame in the layers panel as "LayerInfo". Then after the merge is complete, you can run this simple script:
var doc = app.activeDocument;
var lays = doc.layers;
var tf = doc.textFrames.itemByName("LayerInfo");
var c = tf.parentStory.contents;
var i = lays.length;
while (i--) {
if (lays[i].name == "Poster Design " + c) {
lays[i].visible = true;
} else {
...
Copy link to clipboard
Copied
You’re using Datamerge right?
You can export each 'Poster Design' layers only to individual PDF and add a them in your CSV. So InDesign will place them by itself.
Or you can find someone that can write you a script that can run Datamerge and also turn on off visibility of layers. Don’t expect it to be free.
Copy link to clipboard
Copied
Yeh that is my first option - just it will take some time.
I imagine it wont come free as it seems like a heafty piece of script...
Thanks for your help.
Copy link to clipboard
Copied
The way to do it is to set up the layername field as a non-printing textbox on your merge template, and name that text frame in the layers panel as "LayerInfo". Then after the merge is complete, you can run this simple script:
var doc = app.activeDocument;
var lays = doc.layers;
var tf = doc.textFrames.itemByName("LayerInfo");
var c = tf.parentStory.contents;
var i = lays.length;
while (i--) {
if (lays[i].name == "Poster Design " + c) {
lays[i].visible = true;
} else {
lays[i].visible = false;
}
}
tf.remove();
You could even remove the unwanted layers by changing lays[i].visible = false; to lays[i].remove();
Edit: This assumes that the layers are all named "Poster Design 1", "Poster Design 2", etc. If not, then if "1" corresponds to the layer position in the document, then the if statement would be if ((i+1).toString() == c) {
Edit 2: If you a generating a large merge document for mulitiple products, then you would need additional logic to skip through the pages at the product length interval, copy those pages to a new doc, toggle the appropriate layer, and export. Those bells and whistles are not so free 🙂
Copy link to clipboard
Copied
Not sure i follow your script, but how does this react to data merge? Data merge simply creates an output of all visible layers. So we could easily manually toggle each layer and then either export or do merge data set.
Can you explain how your script actually works in this case? Because if i understand, it simply changes a text in a layer and toggle layer on and off
EDIT
i guess if you added data merge into the layer-visibilty toggle, then it would be useful. Perhaps im mixing things up. I guess your script can be simply run on each showing data set.
EDIT 2
I guess your script can work. I thought a bit more about it. When you do the data-merge. it will also do all the layers. So we can a merged document with all those layers. Then we rnu your script. I guess thats how it was meant., wasnt really clear at first
Copy link to clipboard
Copied
Script uses "control" TextFrame and its contents as a trigger / condition which layer should be ON.

