java script required to create 2 new layers then name them (windows)

New Here ,
Mar 24, 2021 Mar 24, 2021

Copy link to clipboard

Copied

Hi all,

THE CHALLENGE....

I import various Autocad drawings into Illustrator daily for packaging designs.

I need a java script to create 2 new layers, then name them as Dielines and ART.

 

I've tried the script below that creates 2 new layers but I'm not sure how to rename them?

The trial script below does not achieve a rename.

 

app.activeDocument.layers.add;
app.activeDocument.layers.getByName('Layer')rename.('Dieline');.
app.activeDocument.layers.add;
app.activeDocument.layers.getByName('Layer')rename.('Art');.

 

The Autocad drawings that are imported vary in the ammount of layers they contain.

Can ayone help as I'm sure there are lots of ways to achieve the result I want but I'm a newbie to this.

 

Many thanks in advance.

 

 

TOPICS
How to, Import and export, Scripting

Views

125

Likes

translate

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

Adobe Community Professional , Mar 24, 2021 Mar 24, 2021
Hi, I have updated the @femkeblanco script, add is the method therefore it must have () brackets after add. Here you go var layer1 = app.activeDocument.layers.add(); layer1.name = 'Dieline'; var layer2 = app.activeDocument.layers.add(); layer2.name = 'Art';      

Likes

translate

Translate

Translate
Enthusiast ,
Mar 24, 2021 Mar 24, 2021

Copy link to clipboard

Copied

var layer1 = app.activeDocument.layers.add;
layer1.name = 'Dieline';
var layer2 = app.activeDocument.layers.add;
layer2.name = 'Art';

Likes

translate

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
Adobe Community Professional ,
Mar 24, 2021 Mar 24, 2021

Copy link to clipboard

Copied

Hi,

I have updated the @femkeblanco script, add is the method therefore it must have () brackets after add. Here you go

var layer1 = app.activeDocument.layers.add();
layer1.name = 'Dieline';
var layer2 = app.activeDocument.layers.add();
layer2.name = 'Art';

 

 

 

Best regards

Likes

translate

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 ,
Mar 24, 2021 Mar 24, 2021

Copy link to clipboard

Copied

Oops.  Thanks.  

Likes

translate

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 ,
Mar 24, 2021 Mar 24, 2021

Copy link to clipboard

Copied

thankyou Femkeblanco This works well 🙂 

Likes

translate

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