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

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
Import and export , Scripting

Views

350

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 , 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';

 

 

 

Votes

Translate

Translate
Adobe
Guide ,
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';

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 ,
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

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

Copy link to clipboard

Copied

Oops.  Thanks.  

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

Copy link to clipboard

Copied

thankyou Femkeblanco This works well 🙂 

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
New Here ,
Nov 11, 2021 Nov 11, 2021

Copy link to clipboard

Copied

Hello, I'm a newbie as well. Think I can make use of this script, if i only new how to actually download it and where to actaully place it then run it. Any guidance will be GREATLY! appreaciated. Thanks

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 ,
Nov 11, 2021 Nov 11, 2021

Copy link to clipboard

Copied

LATEST

Hola rubia, copy the script posted here, paste it in a Text Editor, save it with any name with a "*.jsx" extension.

Make sure you save as Plain Text (NOT Rich Text).

 

Then go to Illustrator, open a document and click on File->Scripts->Other Scripts...find the script you just saved, done.

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