skip to Main Content

I have made a script for Adobe Illustrator. But I have a problem: I need some functions to be applied step-by-step (asynchronically). These functions are: prepareToScript, selectTextObjects, mergeTextObjects, moveNamesToNewLayer or leaveNamesOnCurrentLayer. Is it possible to do that? Here is the part of the code:

function runThisScript() {

  var doc = app.activeDocument;

    doc.selection = null;
    var layer = doc.activeLayer;

    var layer = doc.layers.getByName("Layer 1");

    doc.activeLayer = layer;

    prepareToScript();
    selectTextObjects();
    mergeTextObjects();

  if (processAllChk.value) {
    processAllNames();
    app.preferences.setStringPreference(allKey, "true");
  }

  if (moveNamesChk.value) {
    moveNamesToNewLayer();
  } else {
    if (!wasTrans) {
        leaveNamesOnCurrentLayer();
    }
    moveNamesToNewLayer();
  }
}

I have tried callbacks and awaits. Either I did something wrong or they don’t work in Adobe Illustrator.

2

Answers


  1. await only works in async functions. Try to write async before the function keyword.

    Login or Signup to reply.
  2. If you mean the classic Extendscript (the legacy Adobe’s variant of Javascript, jsx files) the answer is ‘No’. It has no async/await functions.

    If you mean the new UPX-scripting it’s another matter. But, as far as I know UPX doesn’t work with Adobe Illustrator for now: https://community.adobe.com/t5/illustrator-discussions/when-will-adobe-uxp-for-illustrator-be-released/td-p/13473663

    If you mean the scripting for CEP panel, there is the modern Javascript but it works only within the CEP interface. As soon as you need to get the access to the graphic inside your document you have to call the classic Extendscript script again with all its limitations.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search