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

Multiple artboards to multiple layers

Community Beginner ,
Feb 28, 2017 Feb 28, 2017

Copy link to clipboard

Copied

Hello everyone, I have this script to convert multiple layers to multiple artboards, and also copy each layer name to artboards.

The problem is how to reserve the this script process?

I mean to converts artboards to layer and copy artboards name to layer. Thanks

 

#target illustrator 

 

main(); 

 

function main() { 

   

          if ( app.documents.length == 0 ) { return; } 

 

          var doc = app.activeDocument; 

   

          doc.layers[0].hasSelectedArtwork = true; 

   

          doc.fitArtboardToSelectedArt( 0 ); 

   

          doc.selection = null; 

 

          for ( var  i = 1; i < doc.layers.length; i++ ) { 

   

                    doc.artboards.add( [0,0,72,-72] ); 

   

                    doc.layers[i].hasSelectedArtwork = true; 

   

                    doc.fitArtboardToSelectedArt( i ); 

   

                    doc.selection = null; 

 

          }; 

 

};

 

if (app.documents.length == 0) {

    alert("No Open / Active Document Found");

} else {

    var doc = app.activeDocument;

    if (doc.artboards.length == doc.layers.length && doc.layers.length == doc.artboards.length) {

        for (var i = 0, l = doc.artboards.length; i < l; i++) {

            var ab = doc.artboards[i];

            ab.name = doc.layers[i].name;

        }

        alert("Finished:\nRenaming of Artboards to match Layer names is complete");

    } else {

        alert("Opps: This wont work!\n The number of Layers and Artboards do not match");

    }

}

TOPICS
Scripting

Views

4.6K

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 01, 2017 Mar 01, 2017

Here you go.

 

function layersFromArtboards()

{

    var docRef = app.activeDocument;

    var layers = docRef.layers;

    var aB = docRef.artboards;

 

    //we will remove this layer after the others have been created.

    var tempLay = layers[0];

    tempLay.name = "Temp";

 

    //loop the artboards

    for(var x=0;x<aB.length;x++)

    {

        var thisAb = aB[x];

        aB.setActiveArtboardIndex(x);

        docRef.selectObjectsOnActiveArtboard();

        var sel = docRef.selection;

 

       

...

Votes

Translate

Translate
Adobe
Community Beginner ,
Sep 15, 2021 Sep 15, 2021

Copy link to clipboard

Copied

Hello, could someone make this script into a download, I seem to lack the know-how of creating a javascript documento to run this script from the source code.


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
Guide ,
Sep 16, 2021 Sep 16, 2021

Copy link to clipboard

Copied

Copy and paste it in a jsx file. (You can create a txt file and change the extension to jsx.)  Then, while your document is open in Illustrator, go to File > Scripts > Other Script (Ctrl+F12).  Find your script and open it.

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 ,
Sep 16, 2021 Sep 16, 2021

Copy link to clipboard

Copied

Hi dario, copy the script posted here, open a text editor and paste the copied text. Save the file as "pickAgoodName.jsx", save it as Plain text (not Rich Text Format) anywhere you can easily find it.

 

to run in illustrator go to, File->Scripts->Other Scripts... and browse to where you saved the file

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 Beginner ,
Sep 16, 2021 Sep 16, 2021

Copy link to clipboard

Copied

Thank you so much Carlos. I will try it early next week. Much appreciated. 

 

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