EDOBE XDOM TPC Technical Information Page 44

  • Download
  • Add to my manuals
  • Print
  • Page
    / 68
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 43
44
5
Scripting with JavaScript
This chapter uses script examples and explanations to help you to become familiar with Illustrator
scripting using JavaScript.
For more information
Several extended sample scripts are in the /Scripting/Sample Scripts folder in your Illustrator CS5
installation directory.
For information about individual classes, objects, properties, methods, and parameters, as well as script
samples that demonstrate how to use many of these items, see Adobe Illustrator CS5 Scripting Reference:
JavaScript, in the
/Scripting/Documentation folder in your Illustrator CS5 installation directory. You also
can use the Illustrator dictionary, which you access from the Object Model Viewer in the ESTK. For
information on using the ExtendScript Toolkit and the Object Model Viewer, see
Viewing the JavaScript
object model” on page 9 or JavaScript Tools Guide.
If you do not understand the concepts and terms used in this chapter, read Adobe Introduction to Scripting.
Your first Illustrator script
The traditional first project in any programming language is displaying the message “Hello World!” In this
example, you create a new Illustrator document, then add a text frame containing this message. Follow
these steps:
1. Using any text editor (including Adobe
InDesign
®
or the ESTK), enter the following text:
//Hello World!
var myDocument = app.documents.add();
//Create a new text frame and assign it to the variable "myTextFrame"
var myTextFrame = myDocument.textFrames.add();
// Set the contents and position of the text frame
myTextFrame.position = [200,200];
myTextFrame.contents = "Hello World!"
For information on locating the ExtendScript Toolkit, see Viewing the JavaScript object model” on
page 9.
2. To test the script, do either of the following:
X If you are using the ESTK, select Adobe Illustrator CS5 from the drop-down list in the upper-left corner,
select Yes to start Illustrator, then choose Debug > Run in the ESTK to run the script.
X If you are using a different text editor than the ESTK, save the file as text-only in a folder of your choice,
using the file extension
.jsx, then start Illustrator. In Illustrator, choose File > Scripts > Other Scripts,
and navigate to and run your script file.
T
IP: To add the script to the Illustrator Scripts menu (File > Scripts), save the script in the Scripts folder. The
script will appear on the menu the next time you start Illustrator. For details, see
Installing scripts in the
Scripts menu” on page 10.
Page view 43
1 2 ... 39 40 41 42 43 44 45 46 47 48 49 ... 67 68

Comments to this Manuals

No comments