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

Can't access artboards from "palette" dialog window in Illustrator

Community Beginner ,
Jan 28, 2022 Jan 28, 2022

Copy link to clipboard

Copied

Hey!

Has anyone dealt with this issue? I've made a simple UI window with a button (click -> creates a new artboard). The script works when the window mode is "dialog", but as soon as I change it to "palette" I'm not even able to print out the number of artboards from the EventListener.

Adobe Illustrator 26.0.2

OS: Windows 10

 

Code:

function duplicateArtboard(e){
  alert(app.documents[0].artboards);
}

function create(e){
  alert("function works")
}

function illustratorUI(){
    _win = new Window("palette", 'Print Infosheet test', undefined,  
    {closeButton:true, borderless:false});
    
    _group = _win.add('panel'); //, [20, 20, 200, 200]);
    _group.orientation = "column";

    var button1 = _group.add('button', [40, 365, 250, 400], 'Create', {name:"Create"});  // x, y, right, bottom
    button1.addEventListener("click", create);

    var button2 = _group.add('button', [40, 400, 300, 435], 'Add', {name:"Add"});  // x, y, right, bottom
    button2.addEventListener("click", duplicateArtboard);
    
    if (_win.show() == 1){
        return 1
      }
      else {
        return 0
      }
}
TOPICS
Scripting , SDK , Third party plugins

Views

120

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 Beginner , Jan 28, 2022 Jan 28, 2022

Understood what was wrong. In case anyone is having a similar issue, refer to this thread.

The problem was that palette buttons have to communicate the message to Illustrator (or any other Adobe software) via Bridge. so in my case it was enough modifying the create function:

function create(e){
  var messenger = new BridgeTalk;
  messenger.target = "illustrator";
  messenger.body = "alert(app.activeDocument.artboards.length);";
  messenger.send();
}

Votes

Translate

Translate
Adobe
Community Beginner ,
Jan 28, 2022 Jan 28, 2022

Copy link to clipboard

Copied

LATEST

Understood what was wrong. In case anyone is having a similar issue, refer to this thread.

The problem was that palette buttons have to communicate the message to Illustrator (or any other Adobe software) via Bridge. so in my case it was enough modifying the create function:

function create(e){
  var messenger = new BridgeTalk;
  messenger.target = "illustrator";
  messenger.body = "alert(app.activeDocument.artboards.length);";
  messenger.send();
}

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