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

Set visibility and select sublayers via CSV

Explorer ,
Jun 30, 2025 Jun 30, 2025

Hey All,

  I've previously asked this with objects and it works, but I have since realized that layers & sublayers are the better way for me to do this as I need to create clipping masks using the selections. I'm using Illustrator CS6 and a mac.

I need to figure out how to load and select a specific column from the CSV to set visibility of and select specific sublayers. 

CSV File: printfile.csv
For artboard Front:
-Show only the sublayers found in the csv column “frontVisible” , each of the sublayers are listed in a cell  separated by a comma ,
-Once visibility is set, I need to select 1st & 2nd array items. I will run a resize script below from Jduncan and then I would like to select all of the visible layers in the artboard so I can create a clipping mask. 

I've tried a few different ways to load the data from the csv and I am doing something wrong because it does not work. here is one that I have tried. 

function select () {
var doc = app.activeDocument;
var outlinesFrame = app.activeDocument.layers.getByName("frontVisible");
var outlinesArray = outlinesFrame.contents.split(/,/g);
for(i=0;i<len;i++)
{
   lay= app.activeDocument.layers.getByName("frontVisible");
   lay.hasSelectedArtwork=true;  
    }
}
select();

 

Any help would be appreciated.
Thanks!

TOPICS
Scripting
480
Translate
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 07, 2025 Jul 07, 2025

Thank you for your response. Now I will provide you with a part that may be useful. This is not a script that will directly generate the result you expect after execution, but it will work as an example of the operation you want to do.

// unlock all locked object
app.executeMenuCommand('unlockAll') ;

// show all hidden object
app.executeMenuCommand('showAll') ;

// select all editable object
app.executeMenuCommand('selectall') ;


// get sublayers and make them editable
var doc = app.activeDocu
...
Translate
Adobe
Explorer ,
Jul 04, 2025 Jul 04, 2025

Is this something that just isn't possible via CSV & sublayers?

Translate
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 06, 2025 Jul 06, 2025

To answer your question, we first need to clarify what you finally want to do. It seems that you want to create a clipping mask, which of the following is your wish?

 

  1. Object > Clipping Mask > Make
  2. Layers Panel > Make Clipping Mask
Translate
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 06, 2025 Jul 06, 2025

Object-Clipping Mask-Make is what I plan to use if I can get this working correctly.

my end goal is to use this script along with data variables.

The reason the object level script isn't working is because in order to get the script to read the labels, they have to be visible, but then I can't get the clipping masks to work because of the labels.

Translate
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 06, 2025 Jul 06, 2025

Thank you for clarifying your goals. Next, is it possible for you to present what you mean by “label”? Does it mean a Text String type variable?

Translate
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 06, 2025 Jul 06, 2025

Yes, here is the post showing what I had previously done to get the visibility and selection.
illustrator-script-to-toggle-object-visibility-from-csv-data-variables 

Translate
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 06, 2025 Jul 06, 2025

So I've been playing around with the rezie & align script and I've got that set up to do everything I need after the selection is made. But I still just need the initial layer selections from the csv.

so to edit what I need

"For artboard named "Front" :
-Show only the Layers found in the csv column “frontVisible” , each of the layers are listed in a cell separated by a comma
-Once visibility is set, I need to select all the visible layers on the artboard.

Translate
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 06, 2025 Jul 06, 2025

Hmmm, it seems like an endless process, as each answer adds a new concept.

 

So, as a suggestion, how about first writing down all the steps that the program should do in your native language before you program it? That means it is detailed enough that it can be cross-translated with the program.

 

That way, you can organize and communicate your own wishes to others, and if there are parts that are impossible or too difficult to achieve, the scripting experts will be able to detect them.

Translate
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 06, 2025 Jul 06, 2025

This is the whole thing I want to do, but I have the harder ones sorted now, its just the initial selection that I'm trying to determine if it can be done with layers & an array or not.

So there are four different artboards but the process is close the the same for each. 
As an example, here is the process I was thinking of:
CSV File: printfile . csv
For artboard Front:
-Show only the sublayers found in the csv column “frontVisible” , an array separated by a “;”

-Select all active layers

-Run resize & align script on specific layers ---DONE
-Create a clipping mask with the top object ---DONE
-for Sidepanels layer, use csv data from columns sidepanelColour, sidepanelStrokeWeight, sidepanelStrokeColour to adjust the layer if not blank (not that big of a deal to be scripted, I can just do this before running the variables)
-use variables from the csv to assign font colour and stroke to the variable text (not that big of a deal to be scripted, I can just do this before running the variables)
-rescale artboard to fit art --done
-rotate everything 90 degrees -- done
-save a copy as a pdf, rbg 1998 colour, preserve spot colours --- done

Translate
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 07, 2025 Jul 07, 2025

Thank you for your response. Now I will provide you with a part that may be useful. This is not a script that will directly generate the result you expect after execution, but it will work as an example of the operation you want to do.

// unlock all locked object
app.executeMenuCommand('unlockAll') ;

// show all hidden object
app.executeMenuCommand('showAll') ;

// select all editable object
app.executeMenuCommand('selectall') ;


// get sublayers and make them editable
var doc = app.activeDocument ;
var frontVisibleLayer = doc.layers.getByName('frontVisible') ;

var frontVisibleContents = 'layer 1;layer 2' ;
var frontVisibleSublayerNames = frontVisibleContents.split(';') ;
for(var i = 0, len = frontVisibleSublayerNames.length ; i < len ; i++) {
  var currentSublayer = frontVisibleLayer.layers.getByName(frontVisibleSublayerNames[i]) ;

  // make a sublayer editable
  currentSublayer.locked = false ;
  currentSublayer.visible = true ;
}
Translate
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 12, 2025 Jul 12, 2025

Thank you for this.

So to be sure this script is:
unlocking and showing all layers.

looking for layers named "frontVisible" and assigning them to the variable frontVisibleLayer?

Then getting the sublayer names and assigning them to frontVisibleSublayerNames?

 

 

Or am I misunderstanding it?

Translate
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 12, 2025 Jul 12, 2025
LATEST

Sorry, I am unable to understand what you are asking.

 

As the previous comment states, that script is a collection of parts, so it does not by itself result in a useful result. Please help the script you are working on by applying the parts that might be available.

Translate
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