Taking Advantage of Automation in IllustratorAlthough automation may sound like a scary technical word, it doesn't have to be. Illustrator supports automation via two methods:Actions. This feature within the Illustrator application contains a set of recorded steps that can you can reproduce by clicking a button. For example, an action may contain the steps necessary to select all text objects in an open document and rasterize them at a specific resolution. Actions are simple to record and don't require any code writing knowledge. However, not every feature in Illustrator is actionable, so there's a limit to what an action can do.Scripting. Scripting is essentially a programmatic way to interact with an application. Instead of clicking with a mouse or punching a few keys on your keyboard to control Illustrator, you use a scripta set of commands that instructs Illustrator what to do. Because these commands can contain math and logic, a script can create artwork based on variables. For example, a script might draw a graph in which numbers above a certain amount appear in black and lower numbers appear in red. Most of Illustrator's functionality is available through scripting (significantly more so than with Actions), but to use scripting, you do need to know a scripting language. Illustrator supports AppleScript (Mac), Visual Basic (Windows), and JavaScript (cross-platform) languages. In this appendix, we'll explore these two automation methods as they pertain to Illustrator, and hopefully, this will serve as inspiration for you learn more about automation. ActionsRecording an action is very simple and straightforward in Illustrator; playing back an action is even easier. To access the list of preset actions via the Actions palette, choose Window > Actions. The 22 actions in Illustrator are grouped within the Default Actions set. In addition, you can also create your own sets and actions.To create a new set and an action within it, follow these steps:
ScriptingIllustrator can be scripted using AppleScript, Visual Basic Scripting, or JavaScript. Actually, Illustrator uses a language called ExtendScript, which is an Adobe flavor of JavaScript. You can find resources for this language, such as scripting dictionaries and samples scripts, in the Adobe Illustrator CS2 > Scripting folder.In general, ExtendScript is used to drive functionality within the application itself. For example, an ExtendScript script might be used to reverse the direction of a selected vector path. In contrast, AppleScript or Visual Basic scripting can be used to drive functionality that uses different applications. For example, an AppleScript script might pull data from an external file or from the Web, use that data to generate a graphic, and then export that graphic in a specified format and email it.Each of the sample scripts included with Illustrator either contain separate PDF files describing how the script works or comments embedded directly within the script. You can open and view a script using a script editor or any text editing applications, such as BBEdit, TextEdit, or TextPad.
|