Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


JavaScript to find a specific Layer

New Here ,
Jun 16, 2021 Jun 16, 2021

Copy link to clipboard

Copied

Hi all,

 

I have been looking into the scripting side of Illustrator and have been struggling to get my head around things.

 

I am trying to create a simple code that would find a layer by name/ID and change its content.

 

I can create a code to create a new layer, but I am struggling to modify this to allow me to change a layer that already exists.

 

 

 

Any help is greatly appreciated.

TOPICS
Scripting

Views

141

Likes

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
Enthusiast ,
Jun 16, 2021 Jun 16, 2021

Copy link to clipboard

Copied

A layer named "Layer 1" is referenced as such

app.activeDocument.layers["Layer 1"]

 

For example, to lock layer "Layer 1"

app.activeDocument.layers["Layer 1"].locked = true;

 

Or, to remove all path items from layer "Layer 1"

app.activeDocument.layers["Layer 1"].pathItems.removeAll();

 

Likes

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
New Here ,
Jun 16, 2021 Jun 16, 2021

Copy link to clipboard

Copied

LATEST

Thanks so much for your quick response - will give this a go.

 

Thanks again

Likes

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