• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Data Merge with Variable Layer Visibility

Explorer ,
Jul 29, 2022 Jul 29, 2022

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

TOPICS
Feature request , How to , Scripting

Views

882

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jul 29, 2022 Jul 29, 2022

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 {
      
...

Votes

Translate

Translate
Community Expert ,
Jul 29, 2022 Jul 29, 2022

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 29, 2022 Jul 29, 2022

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 29, 2022 Jul 29, 2022

Copy link to clipboard

Copied

LATEST

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 🙂

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines