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

Is ScriptUI in Illustrator broken?

Community Beginner ,
Mar 10, 2023 Mar 10, 2023

Coming from a familiarity with scripting panels in After Effects, I'm really confused about how to accomplish the same tasks in Illustrator. 

 

In After Effects, I can create a dockable dialog with access to the whole project.  But something seems to be broken in Illustrator's implementation of ScriptUI.   If I create a "palette" window, basic user functions in Illustrator work (selecting objects, navigating, etc.), but the palette window script has no access at all to the active document, so all my pretty buttons in the script window that do the awesome things are useless.

 

If I simply change "palette" to "window", my script has access again to the document - but now Illustrator's interface is locked until I close the script window.  My pretty buttons are useless again except on whatever layer or objects I happen to have selected when I run the script - which defeats the purpose of using a window, since I might as well be executing a one-off script to do the same operation. 

 

Am I crazy or doing something incorrectly? Or is Illustrator's implementation of ScriptUI really just this borked?

TOPICS
Bug , Scripting , Tools
1.1K
Translate
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
Adobe
Community Expert ,
Mar 10, 2023 Mar 10, 2023

Try looking for some pointers in this

Peter Kahrel, ScriptUI for Dummies

 

Translate
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
Mentor ,
Mar 10, 2023 Mar 10, 2023

There's a long and old discussion here - https://community.adobe.com/t5/illustrator-discussions/script-ui-breaks-connection-with-ai-document/... I'm not a scripter so I don't know if any of it is valuable to you or not... There's probably other discussions on this forum.

Translate
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 ,
Mar 10, 2023 Mar 10, 2023

I've not looked into "palettes" properly (I use "dialog" windows), but when I tried them in the past, Illustrator seemed to respond to some events and not others.  Those others had to be passed through BridgeTalk.  See this answer and the thread it links to.  

Translate
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 ,
Mar 10, 2023 Mar 10, 2023
LATEST

Yeah, I have only experimented with palettes and BridgeTalk a little bit because it's messy but here is a script I wrote the other day to answer a question on this forum about clicking buttons in a palette. Basically, you send a string of the code you want to run to Ai via BridgTalk and it gets executed as it happened from within your script. Hopefully, this can get you going in the right direction. Also, if you dig into some of the scripts in the Ai system files on your computer you can see the use of BridgeTalk in quite a few places. may give you some more ideas. Cheers!

 

/*
ButtonOnClickFromPalette.jsx for Adobe Illustrator
--------------------------------------------------

Execute a palette button onClick function via BridgeTalk.

Created in response to this question on the Adobe forum:
https://community.adobe.com/t5/illustrator-discussions/copy-a-string-to-clipboard-at-launch-via-javascript/td-p/13616550
*/

var SWD = "SOME TEXT TO COPY";
var URL = "https://adobe.com/";

// the BridgeTalk Object
var bt = new BridgeTalk();

// the communication target
bt.target = "illustrator";

// The script to be executed as a String
var codeAsString =
  "app.activeDocument.selection = null;" +
  "\n" +
  "var tempObj = app.activeDocument.pathItems.add();" +
  "\n" +
  "var myText = app.activeDocument.textFrames.add();" +
  "\n" +
  'myText.contents = "' +
  SWD +
  '";' +
  "\n" +
  "tempObj.selected = true;" +
  "\n" +
  "myText.selected = true;" +
  "\n" +
  "app.copy();" +
  "\n" +
  "tempObj.remove();" +
  "\n" +
  "myText.remove();" +
  "\n" +
  'var html = new File(Folder.temp.absoluteURI + "/aisLink.html");' +
  "\n" +
  'html.open("w");' +
  "\n" +
  "var htmlBody = " +
  "\"<html><head><META HTTP-EQUIV=Refresh CONTENT='0; URL=" +
  URL +
  "'></head><body><p></body></html>\";" +
  "\n" +
  "html.write(htmlBody);" +
  "\n" +
  "html.close();" +
  "\n" +
  "html.execute();";

// assign to the object's body the message
bt.body = codeAsString;

// make your dialog (not palette)
var win = new Window("palette");
win.text = "DC TOOLS";
// make your button
var button = win.add("button", undefined, "PACK");
// add all the things you want done when button is clicked
button.onClick = function () {
  // send the message to the target app
  bt.send();
};
// show the dialog
win.show();

 

dad x 2. designer. maker. fun haver. ‍
Translate
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