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

documents[i].artboards.length not working (illustrator scripting)

Community Beginner ,
Sep 01, 2017 Sep 01, 2017

Copy link to clipboard

Copied

Hi there!

I'm working on an illustrator extendscript where I have to get number of artboards for each opened document. The code may look like this

for (  var i=0  ;  i<app.documents.length  ;  i++  ) {

              alert(app.documents.artboards.length);

     }

But each time I run this script, it returns the number of artboards for active document (only) each time.

for example if I've 3 documents opened ie. doc1 , doc2 , doc3

the number of artboards in doc1 is 1, doc2 is 4, and in doc3 is 2

and I'm currently working with doc2 ( doc2 is active)

then the script alerts 3 times saying: 4, 4 and 4 each time.

please help me

Also tell me if this code is correct or not

thanks in advance

update: I also tried alert( app.documents[1].artboards.length ); , It doesn't work either. having the same problem with this too (shows no: of artboards for active doc)

Tell me if I'm doing wrong

TOPICS
Scripting

Views

1.1K

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

Hi sajidk54358625​,

does this helps you on your way?

for ( var i=0; i<app.documents.length; i++ ) {

    app.documents.activate();

    alert(app.activeDocument.name);

    alert(app.activeDocument.artboards.length);

    }

Have fun

Votes

Translate

Translate
Adobe
Community Expert ,
Sep 01, 2017 Sep 01, 2017

Copy link to clipboard

Copied

Hi sajidk54358625​,

does this helps you on your way?

for ( var i=0; i<app.documents.length; i++ ) {

    app.documents.activate();

    alert(app.activeDocument.name);

    alert(app.activeDocument.artboards.length);

    }

Have fun

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
Valorous Hero ,
Sep 01, 2017 Sep 01, 2017

Copy link to clipboard

Copied

Interesting, it makes me think that artboards are indeed treated apart from other kinds of items in Illustrator documents. In the following lines, the only problematic item is the artboard count.

  for (  var i=0 ;  i < app.documents.length ;  i++  ) {

    alert("Name: " + app.documents.name + ". PathItems: " + app.documents.pathItems.length + ". Layers: " + app.documents.layers.length + ". Artboards: " + app.documents.artboards.length + ".");

  }

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

Copy link to clipboard

Copied

IMHO artboards are only available in the active document. That's why activeDocument.artboards.length is possible - but not documents.artboards.length

for ( var i=0; i<app.documents.length; i++ ) {

    app.documents.activate();

    var aDoc = app.activeDocument;

    alert("Name: " + aDoc.name + ". PathItems: " + aDoc.pathItems.length + ". Layers: " + aDoc.layers.length + ". Artboards: " + aDoc.artboards.length + ".");

}

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

Copy link to clipboard

Copied

thanks for your ideas! it really helped me

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 ,
Dec 26, 2023 Dec 26, 2023

Copy link to clipboard

Copied

LATEST

You can follow this post which discusses the same issue. And there is a bug report you can vote on.

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