Taking Advantage of Automation in Illustrator


Although 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.

Actions

Recording 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:

1.

Choose Window > Actions to open the Actions palette (Figure A.1).

Figure A.1. You'll find the Default Actions in the Actions palette. You can create your own sets as well.


2.

Click the Create New Set icon at the bottom of the Actions palette. Give your set a unique name and click OK.

3.

Click the Create New Action icon at the bottom of the Actions palette. When you do, Illustrator prompts you to name the action you're about to record. Choose the set that you just created, and if you'd like, choose a function key so that later you can perform the Action using a keystroke. When you're done, click OK.

4.

At this point, you'll notice that the red recording icon at the bottom of the Actions palette is highlighted, indicating that recording has begun. Perform the steps that you want to record in Illustrator.

You can see each step being added as a line item to your action as you perform it. If a step doesn't appear in your action, it is probably because the function you performed is not actionable.

5.

Once you have completed the steps for your action, click the Stop Recording button. At this point, the action is complete.

To apply Actions with a single click, you can activate Button mode in the Actions palette. Choose Button Mode from the Actions palette menu.



To play back your actionor any other onehighlight it in the Actions palette and click the Play Current Selection button. If you assigned a keystroke to your Action, you can play it back by pressing the correct key combination on your keyboard.

Scripting

Illustrator 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.

Illustrator includes a PDF entitled "Getting Started with JavaScript," which is a wonderful resource for those of you who want to learn more about scripting in Illustrator.






Real World Adobe Illustrator CS2
Real World Adobe Illustrator CS2
ISBN: 0321337026
EAN: 2147483647
Year: 2003
Pages: 147
Authors: Mordy Golding

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net