Java Script in Illustrator

JavaScript is an embedded programming language, and the objects and methods available to it depend on the environment in which it is embedded.

KM Execute's JavaScript actions evaluate code in the JXA context, which has access to a special Automation object, with similar scope to AppleScript, but has no access to the other (entirely separate and unrelated) JS contexts of the various embedding in web browsers, Omni Apps, TaskPaper, QuarkXpress, or Adobe apps etc etc

The Illustrator activeDocument object and its various methods and properties are only available to code evaluated by the JS interpreter embedded in Illustrator. They are not available to the JXA JS interpreter.

What you can do, however, is pass the code string to the Illustrator.doScript method, which will then pass the code to Illustrator's own JS context, and execute it there.

See, for example, this thread:

2 Likes