Adobe 65010248 Scripting Guide

Adobe 65010248 - Illustrator CS4 - PC Manual

Adobe 65010248 manual content summary:

  • Adobe 65010248 | Scripting Guide - Page 1
    ADOBE® ILLUSTRATOR® CS4 ADOBE ILLUSTRATOR CS4 SCRIPTING GUIDE
  • Adobe 65010248 | Scripting Guide - Page 2
    rights reserved. Adobe Illustrator CS4 Scripting Guide If this guide is distributed with software that includes an end user agreement, this guide, as well organization. Adobe, the Adobe logo, Illustrator, Photoshop, and InDesign are either registered trademarks or trademarks of Adobe Systems
  • Adobe 65010248 | Scripting Guide - Page 3
    Why use scripting 6 What about actions 6 Script support in Adobe Illustrator CS4 7 ExtendScript features 7 ExtendScript tools 7 Script file 10 Executing scripts from the Other Scripts menu item 10 Startup scripts (.jsx scripts only 10 Changes since CS3 11 Known issues 16 2 The Illustrator
  • Adobe 65010248 | Scripting Guide - Page 4
    frames 36 Creating paths and shapes 37 Paths 37 Shapes 38 5 Scripting with JavaScript 40 For more information 40 Your first Illustrator script 40 Adding features to "Hello World 41 Working with methods in JavaScript 41 Accessing and referencing objects 42 Referencing the application
  • Adobe 65010248 | Scripting Guide - Page 5
    Contents 5 Creating paths and shapes 45 Paths 45 Shapes 46 6 Scripting with VBScript 48 For more information 48 Your first Illustrator script 48 Adding features to "Hello World 49 Accessing and referencing objects 49 Obtaining objects from collections 49 Creating new objects 50 Working
  • Adobe 65010248 | Scripting Guide - Page 6
    guide describes the scripting interface to Adobe® Illustrator® CS4. If you are new to scripting or want basic information about scripting and how to use the different scripting languages, see Adobe Introduction to Scripting. What is scripting? A script is a series of commands that tells Illustrator
  • Adobe 65010248 | Scripting Guide - Page 7
    in Adobe Illustrator CS4 7 Script support in Adobe Illustrator CS4 Illustrator scripting supports VBScript and JavaScript scripts for Windows, and AppleScript and JavaScript scripts for Mac OS. NOTE: Also, Adobe scripting-enabled applications, including Illustrator, support ExtendScript, Adobe
  • Adobe 65010248 | Scripting Guide - Page 8
    folder in your Illustrator CS4 installation directory ➤ In the Adobe Illustrator CS4 scripting reference for your scripting language, located in the /Scripting/Documentation folder in your Illustrator CS4 installation directory Viewing the object model Each of the supported scripting languages
  • Adobe 65010248 | Scripting Guide - Page 9
    dialog, find and select Adobe Illustrator CS4, and click Open. Script Editor displays a list of the Illustrator objects and commands, which script. See "Executing scripts from the Other Scripts menu item" on page 10. You also can have JavaScript scripts with a .jsx extension start automatically when
  • Adobe 65010248 | Scripting Guide - Page 10
    When you select the file, the script is executed. Only files that are of one of the supported file types are displayed in the browse dialog. For details, see "Script support in Adobe Illustrator CS4" on page 7. Startup scripts (.jsx scripts only) JavaScript scripts with a .jsx file extension can be
  • Adobe 65010248 | Scripting Guide - Page 11
    Files/Common Files/Adobe/Startup Scripts CS4/Illustrator ➤ Mac OS: :Library:Application Support:Adobe:Startup Scripts CS4:Illustrator If a script JavaScript Tools Guide. Changes since CS3 This section lists changes made to the scripting object model to support features in Illustrator CS4. ➤ A
  • Adobe 65010248 | Scripting Guide - Page 12
    - non native items of document 1 ➣ JavaScript - app.activeDocument.nonNativeItems ➣ VBScript - App.ActiveDocument.NonNativeItems ➤ A new FXG file format supports designer-developer workflow, by allowing an Illustrator document to be saved as an FXG file containing XML-style descriptions of
  • Adobe 65010248 | Scripting Guide - Page 13
    obsolete, with the modification of artboards to support the new, multiple-artboard feature. ➤ Support for JIS90 and JIS04 glyph encoding/forms = app.convertSampleColor(ImageColorSpace.RGB, new Array(93, 32, 10), ImageColorSpace.CMYK, ColorConvertPurpose.defaultpurpose); ➣ VBScript - cmykColor =
  • Adobe 65010248 | Scripting Guide - Page 14
    ➤ A new property in the OpenOptionsAutoCAD class, MergeLayers, defines whether the layers in the AutoCAD file being opened should be merged into a single layer in the Illustrator document. ➣ AppleScript - merge layers: true ➣ JavaScript - mergeLayers = true ➣ VBScript - MergeLayers = true
  • Adobe 65010248 | Scripting Guide - Page 15
    class, Artboard, defines an artboard object or artboard in a CS4 document. It has the following properties: ArtboardRect, RulerPAR, ShowRulers new properties in the PrintJobOptions class, PrintAllArtboards and ArtboardRange, support printing of multiple artboards. ➤ A new type,
  • Adobe 65010248 | Scripting Guide - Page 16
    global, persistent, ExtendScript engine inside Illustrator handles all BridgeTalk communications. The net effect is that the state of the ExtendScript engine is cumulative to all scripts that ran previously. Issues with script code that may cause this problem are: ➣ Reading uninitialized variables
  • Adobe 65010248 | Scripting Guide - Page 17
    Scripting Object Model A good understanding of the Illustrator object model will improve your scripting abilities. The following figure shows the containment hierarchy of the object , which give you operating-system-independent access to the file system. For details, see JavaScript Tools Guide. 17
  • Adobe 65010248 | Scripting Guide - Page 18
    properties, methods, and object are in a monospaced font. Top-level (containing) objects Use these objects to access global information about the Illustrator application or an individual document. Application The properties of the application object give your script access to global values, such as
  • Adobe 65010248 | Scripting Guide - Page 19
    the associated file The document object's methods allow your scripts to act on the document; for example: ➤ Save to an Illustrator file or save as the various supported file formats ➤ Activate or close a document ➤ Print the document. Your scripts can select a printer by referencing a print options
  • Adobe 65010248 | Scripting Guide - Page 20
    object ➤ mesh items object ➤ plugin items object ➤ legacy text items object For details on creating objects of these types, see the Adobe Illustrator CS4 Scripting Reference for your language. Art styles Your script can apply a graphic style to artwork using the graphic style object. To apply
  • Adobe 65010248 | Scripting Guide - Page 21
    document, the type automatically becomes a text frame object and, at the same time, a story object. To observe this, open a new document in Illustrator and use the horizontal text tool to type some text, then use the vertical text tool to type more text. Finally, create a rectangle and type
  • Adobe 65010248 | Scripting Guide - Page 22
    for creating area text frames and path text frames. As in the Illustrator application, you can thread area or path text frames. To thread existing information on creating or threading text frames, see the chapter in this manual for your scripting language. Text geometry While the three kinds of
  • Adobe 65010248 | Scripting Guide - Page 23
    CHAPTER 2: The Illustrator Scripting Object Model Text objects 23 Both text frame and story objects have insertion point and text selection properties. The text frame object's properties also
  • Adobe 65010248 | Scripting Guide - Page 24
    that are stored in the Symbols panel. Your scripts can create, delete, and duplicate symbol objects. When you create symbol objects in your script, Illustrator adds them to the Symbols panel for the target document. A symbol item is an instance of a symbol object in a document. Each symbol item is
  • Adobe 65010248 | Scripting Guide - Page 25
    at the end of the string: For Illustrator 10, use "Illustrator.Application.1" For Illustrator CS, use "Illustrator.Application.2" For Illustrator CS2, use "Illustrator.Application.3" For Illustrator CS3, use "Illustrator.Application.4" For Illustrator CS4, use "Illustrator.Application.CS4" 25
  • Adobe 65010248 | Scripting Guide - Page 26
    There are other types of "active" or "current" object properties, like active dataset or active view. For details, see the Adobe Illustrator CS4 Scripting Reference for your language. Creating new objects Several objects (besides the application object itself ) cannot be obtained from containers or
  • Adobe 65010248 | Scripting Guide - Page 27
    Flash export options GIF export options JPEG export options Photoshop export options PNG8 export options PNG24 export options SVG file folder gradient color gray color Illustrator and folder objects are Adobe ExtendScript devices designed to , see JavaScript Tools Guide. For information on creating
  • Adobe 65010248 | Scripting Guide - Page 28
    , see the document object Elements table in Adobe Illustrator CS4 Scripting Reference: AppleScript or the Properties table in Adobe Illustrator CS4 Scripting Reference: JavaScript or Adobe Illustrator CS4 Scripting Reference: VBScript. A diagram of the Illustrator CS4 object model is in "The
  • Adobe 65010248 | Scripting Guide - Page 29
    utilities. For details, see JavaScript Tools Guide. Em space units Values that use em 10-point font, 1 em equals 10 points. In a 10-point font, a kerning value of 20 em units is equivalent to: (20 units x 10 points) / 1000 units/em = 0.2 points Page-item positioning and dimensions Illustrator
  • Adobe 65010248 | Scripting Guide - Page 30
    and dimensions 30 You can see these coordinates in the Info panel when you select or create an object in Illustrator. The default ruler origin point (0, 0) for coordinate numbering in Illustrator is the lower-left corner of the document. (ruler origin is a property of the document object) On the
  • Adobe 65010248 | Scripting Guide - Page 31
    and shapes 31 Paths and shapes Paths are represented in the Illustrator DOM by the path item object. Path items include all artwork the script to a halt until the dialog is dismissed. This can be a serious problem in an automation environment, where there is no one present to deal with dialogs. The
  • Adobe 65010248 | Scripting Guide - Page 32
    can capture and automate parts of your print workflow. Scripting exposes the full capabilities of Illustrator printing, some of which may not be accessible through the application's user interface. Illustrator supports at most one print session at a time, because of limits in the current printing
  • Adobe 65010248 | Scripting Guide - Page 33
    Adobe Illustrator CS4 Scripting Reference: AppleScript, in the :Scripting:Documentation folder in your Illustrator CS4 installation directory. You also can view the Illustrator CS4 to Illustrator tell application "Adobe Illustrator" -- add the script to the Illustrator Scripts menu (File > Scripts),
  • Adobe 65010248 | Scripting Guide - Page 34
    the object that was worked on most recently. Consider the following sample script: -- Make 2 new objects and try to select both tell application "Adobe Illustrator" set newDocument to make new document set rectPath to make new rectangle in newDocument set starPath to make new star in newDocument set
  • Adobe 65010248 | Scripting Guide - Page 35
    1 of layer 1 of document 1, path item 1 of layer 1 of document 1} A better approach is to reference the objects by name: tell application "Adobe Illustrator" set newDocument to make new document make new rectangle in newDocument with properties {name:"rectangle"} make new star in newDocument with
  • Adobe 65010248 | Scripting Guide - Page 36
    , place the value of the contents property on one line. The long-line character (¬) is not valid within a string value. tell application "Adobe Illustrator" make new document make new rectangle in current document with properties {position:{100, 500}, height:100, width:100} make new text frame in
  • Adobe 65010248 | Scripting Guide - Page 37
    entire path property of the path items object. The following script specifies three pairs of x-y coordinates, to create a path with three points: tell application "Adobe Illustrator" set docRef to make new document -- set stroked to true so we can see the path set lineRef to make new path item in
  • Adobe 65010248 | Scripting Guide - Page 38
    path point types The following script sample creates a path with three points, by combining the entire path property with a path point object: tell application "Adobe Illustrator" set docRef to make new document -- set stroked to true so we can see the path set lineRef to make new path item in
  • Adobe 65010248 | Scripting Guide - Page 39
    the left edge of the page and 2 inches (144 points) from the bottom of the page. Creating a polygon Consider the following sample: tell application "Adobe Illustrator" set docRef to make new document set pathRef to make new polygon in docRef with properties {center point:{144, 288},sides:7,radius:72
  • Adobe 65010248 | Scripting Guide - Page 40
    Guide. If you do not understand the concepts and terms used in this chapter, read Adobe Introduction to Scripting. Your first Illustrator Adobe Illustrator CS4 from the drop-down list in the upper-left corner, select Yes to start Illustrator start Illustrator. In Illustrator, choose File > Scripts >
  • Adobe 65010248 | Scripting Guide - Page 41
    an art object. rotate (angle [,changePositions] [,changeFillPatterns] [,changeFillGradients] [,changeStrokePattern] [,rotateAbout]) In the definition, taken from Adobe Illustrator CS4 Scripting Reference: JavaScript, optional parameters are enclosed in square brackets ([]). To rotate the object 30
  • Adobe 65010248 | Scripting Guide - Page 42
    To obtain a reference to a specific object, you need to navigate the containment hierarchy. Because all JavaScript scripts are executed from within the Illustrator application, however, a specific reference to the application object is not required. For example, to assign the active document in
  • Adobe 65010248 | Scripting Guide - Page 43
    CHAPTER 5: Scripting with JavaScript Accessing and referencing objects 43 The following statements assign the name of the first graphic style in the collection to a variable. You can use these statements interchangeably. var styleName = myStyles[0].name var styleName = firstStyle.name var
  • Adobe 65010248 | Scripting Guide - Page 44
    100, 100); //use the areaText method to create the text frame var areaTextRef = docRef.textFrames.areaText(rectRef); Threaded frames As in the Illustrator application, you can thread area text frames or path text frames. To thread existing text frames, use the nextFrame or previousFrame property of
  • Adobe 65010248 | Scripting Guide - Page 45
    CHAPTER 5: Scripting with JavaScript Creating paths and shapes 45 Threaded frames make a single story object Threaded frames make a single story object. To observe this, run the following JavaScript after running the script in "Threaded frames" on page 44. var myDoc = app.activeDocument alert("
  • Adobe 65010248 | Scripting Guide - Page 46
    "Measurement units" on page 29. ➤ x and y coordinates are measured from the bottom-left corner of the document, as indicated in the Info panel in the Illustrator application. For details, see "Page-item positioning and dimensions" on page 29.
  • Adobe 65010248 | Scripting Guide - Page 47
    CHAPTER 5: Scripting with JavaScript Creating paths and shapes 47 Creating a rectangle Consider the following sample var myDocument = app.documents.add() var artLayer = myDocument.layers.add() var rect = artLayer.pathItems.rectangle( 144, 144, 72, 216 ); The sample uses the pathItems object's
  • Adobe 65010248 | Scripting Guide - Page 48
    Adobe Illustrator CS Scripting Reference: VBScript, in the /Scripting/Documentation folder in your Illustrator CS4 installation directory. You also can view the Illustrator CS4 next time you start Illustrator. For details, see "Installing scripts in the Scripts menu" on page 10. In general, when you
  • Adobe 65010248 | Scripting Guide - Page 49
    active document. ➤ Get the width of the active document. ➤ Resize the text frame item to match the document's width. If you closed the Illustrator document without saving it, run your first script again to create a new document. Follow these steps: 1. Copy the following script into your text editor
  • Adobe 65010248 | Scripting Guide - Page 50
    documentRef.Selection Set topObject = selectedObjects(0) MsgBox(topObject.Typename) The MsgBox method does not display a dialog when the script is run from the Illustrator Scripts menu (File > Scripts). The first object in a selection array is the selected object that was last added to the page, not
  • Adobe 65010248 | Scripting Guide - Page 51
    , 100, 100) ' Use the AreaText method to create the text frame Set areaTextRef = docRef.TextFrames.AreaText(rectRef) Threaded frames As in the Illustrator application, you can thread area path frames or path text frames. To thread existing text frames, use the NextFrame or PreviousFrame property of
  • Adobe 65010248 | Scripting Guide - Page 52
    object. The following script specifies three pairs of x-y coordinates, to create a path with three points: Set appRef = CreateObject ("Illustrator.Application") Set firstPath = appRef.ActiveDocument.PathItems.Add firstPath.Stroked = True firstPath.SetEntirePath(Array(Array(220, 475),Array(375, 300
  • Adobe 65010248 | Scripting Guide - Page 53
    on page 29. ➤ x and y coordinates are measured from the bottom-left corner of the document, as indicated in the Info panel in the Illustrator application. For details, see "Page-item positioning and dimensions" on page 29. Creating a rectangle Consider the following sample: Set appRef = CreateObject
  • Adobe 65010248 | Scripting Guide - Page 54
    of the following: ➤ The object browser in your scripting editor environment. See "Viewing the VBScript object model" on page 9. ➤ The Adobe Illustrator CS4 Scripting Reference: VBScript, which lists the numeral values directly after the constant value in the "Enumerations" chapter at the end of the
  • Adobe 65010248 | Scripting Guide - Page 55
    creating, 33, 40, 48 improving, 34, 41, 49 I Illustrator launching, 25 quitting, 25 specifying a version, 25 Illustrator, See Adobe Illustrator inches, conversion of measurements, 29 installing scripts, 10 J JavaScript changes in Illustrator CS2, 16 file extension, 7 naming conventions, 18 object
  • Adobe 65010248 | Scripting Guide - Page 56
    , 50 scripting about, 6 using, 6 scripting samples creating a rectangle, 53 creating new objects, 50 scripts executing, 9, 10 file extensions, 7 installing, 10 menu, 7 support in Illustrator, 7 SDK, 31 selecting objects, 50 selections determining content, 35, 44, 50 using, 35, 44, 50 Software
  • Adobe 65010248 | Scripting Guide - Page 57
    interaction levels, 31 V variables deleting, 24 using, 24 VBScript enumeration values, 54 file extension, 7 naming conventions, 18 type library, 9 versions of Illustrator, specifying, 25 visible bounds, 30 57 W width, maximum value allowed, 29 write-once, 39 X X axis, 29 Y Y axis, 29 Z zero point
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57

ADOBE
®
ILLUSTRATOR
®
CS4
ADOBE ILLUSTRATOR CS4
SCRIPTING GUIDE