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
}
}
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();
}
Copy link to clipboard
Copied
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();
}