Skip to main content
Inspiring
March 15, 2009
Question

Script to make multiple layers in one task

  • March 15, 2009
  • 14 replies
  • 9265 views
From time to time I find the need to make many empty layers named A-Z. I use this when preparing a font drawn in Illustrator for moving to FontLab.

I have not found any ready made script to do this and would like a little help to make one. Or, if somebody would like to make this script it would be even more helpful.

The situation is this:
A full set of glyphs is ready in Illustrator and all are on Layer 1.
Artboard is set according to: http://font.is/?p=48
Glyphs are aligned to left on top of each other.
Need to make empty layers, A-Z and even more. Tedious by hand.
Then each glyph is moved from the sublayers to their own new layers. I could continue doing this part by hand.

I could of course make these layers in one file and copy them each time to each project but a script would be soooo much cooler.

Any help with this? Hints?

Thanks in advance.
This topic has been closed for replies.

14 replies

try67
Community Expert
Community Expert
March 16, 2009
You can either run it manually by pressing Ctrl+F12 and then selecting the file or by placing it in the Scripts folder, which is typically:
C:\Program Files\Adobe\Adobe Illustrator CSx\Presets\Scripts\

If you choose the latter option the script will appear in the Scripts menu under File, but you will need to re-start Illustrator in order to see it.
Inspiring
March 16, 2009
Hi again.

I have copied the code and saved as a little .js file. I can not get Illustrator to run the file. It is grayed out.

The file looks like this:

//Apply to myDoc the active document

var myDoc = app.activeDocument;
//define first character and how many layers do you need

var layerIniName =65;
var numberOfLayers=25;

//Create the layers

for(var i=0; i<=numberOfLayers; i++) {
var layerName = String.fromCharCode(layerIniName)
var myLayer = myDoc.layers.add(); myLayer.name = layerName layerIniName++
}

Am I doing something wrong?
Inspiring
March 16, 2009
Awww... really cool. Thanks so much.
I'll try it later on, just stuck in a major stress project right now.

You English is about the same quality as mine. (not native language).

I'll report, probably tonight when I have tried this.

Thanks again.
March 16, 2009
Hello Sigurdur,

With the follow JavaScript you can create layers in Illustrator.

layerIniName -> Put here first ASCII code (A=65, a=97)
numberOfLayers -> Put here how many layer do you need

Code:
//Apply to myDoc the active document
var myDoc = app.activeDocument;
//define firts caracter and how many layers do you need
var layerIniName =65;
var numberOfLayers=25;

//Create the layers
for(var i=0; i<=numberOfLayers; i++) {
var layerName = String.fromCharCode(layerIniName)
var myLayer = myDoc.layers.add();
myLayer.name = layerName
layerIniName++
}

I hope it will be usefully for you. Sorry for my english

Santiago