Adobe 65010248 - Illustrator CS4 - PC Скачать руководство пользователя страница 51

C

HAPTER

 6: Scripting with VBScript

Working with text frames

     51

Working with text frames

To create a text frame of a specific type in VBScript, use the 

TextFrames

 method that corresponds to the 

type of frame you want to create:

Set rectRef = docRef.PathItems.Rectangle(700, 50, 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 the 

TextFrames

 object.

When copying the following script to a script or text editor, place the value of the 

Contents

 property on 

one line. The long-line continuation character (

_

) is not valid when enclosed in a string.

Set appRef = CreateObject("Illustrator.Application")
Set myDoc = appRef.Documents.Add
Set myPathItem1 = myDoc.PathItems.Rectangle(244, 64, 82, 76)
Set myTextFrame1 = myDoc.TextFrames.AreaText(myPathItem1)

myTextFrame1.Contents = "This is two text frames linked together as one story, with 

text flowing from the first to the last."
Set myPathItem2 = myDoc.PathItems.Rectangle(144, 144, 42, 116)
Set myTextFrame2 = myDoc.TextFrames.AreaText(myPathItem2)

'Use the NextFrame property to thread the frames
myTextFrame1.NextFrame = myTextFrame2

appRef.Redraw()

Threaded frames make a single story object

Threaded frames make a single 

story

 object. To observe this, run the following VBScript after running the 

script in 

“Threaded frames” on page 51

.

Set myDoc = appRef.ActiveDocument
myMsg = "alert(""There are " & CStr(myDoc.TextFrames.Count) & " text frames. "")"
appRef.DoJavaScript myMsg
myMsg = "alert(""There are " & CStr(myDoc.Stories.Count) & " storiess. "")"
appRef.DoJavaScript myMsg

Creating paths and shapes

This section explains how to create items that contain paths.

Paths

To create a freeform path, specify a series of path points, as a series of either x-y coordinates or 

PathPoint

 

objects.

Содержание 65010248 - Illustrator CS4 - PC

Страница 1: ...ADOBE ILLUSTRATOR CS4 ADOBE ILLUSTRATOR CS4 SCRIPTING GUIDE...

Страница 2: ...r other countries Microsoft and Windows are either registered trademarks or trademarks of Microsoft Corporation in the United States and or other countries Apple Mac Macintosh and Mac OS are trademark...

Страница 3: ...e VBScript object model 9 Executing scripts 9 Installing scripts in the Scripts menu 10 Executing scripts from the Other Scripts menu item 10 Startup scripts jsx scripts only 10 Changes since CS3 11 K...

Страница 4: ...ocuments 32 4 Scripting with AppleScript 33 For more information 33 Your first Illustrator script 33 Adding features to Hello World 34 Object references 34 Obtaining objects from documents and layers...

Страница 5: ...Illustrator script 48 Adding features to Hello World 49 Accessing and referencing objects 49 Obtaining objects from collections 49 Creating new objects 50 Working with selections 50 Working with text...

Страница 6: ...o write short simple scripts that perform repetitive tasks for you As your scripting skills grow you can move on to more complex scripts Scripting also can enhance your creativity by quickly performin...

Страница 7: ...omplete documentation of the methods and properties of JavaScript objects For information on accessing the ESTK and the Object Model Viewer see Viewing the JavaScript object model on page 8 ExtendScri...

Страница 8: ...OS system drive Applications Utilities Adobe Utilities ExtendScript Toolkit CS4 2 In the ESTK choose Help Object Model Viewer 3 In the Object Model Viewer window select Adobe Illustrator CS4 Type Lib...

Страница 9: ...ls Macro Visual Basic Editor 2 In the Visual Basic Editor choose Tools References 3 In the dialog that appears select the check box for Adobe Illustrator CS4 Type Library and click OK 4 Choose View Ob...

Страница 10: ...le 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 js...

Страница 11: ...the Add method in the Document class Possible layouts are GridByRow GridByCol Row Column RLGridByRow RLGridByCol and RLRow for example AppleScript artboardLayout grid by row JavaScript DocumentArtboa...

Страница 12: ...type FiltersPreservePolicy which defines whether to preserve appearance and editability of filters when saving to FXG Available options are ExpandFilters RasterizeFilters and KeepFiltersEditable Apple...

Страница 13: ...example AppleScript alternate glyphs jis90 JavaScript AlternateGlyphsForm JIS90 VBScript AiAlternateGlyphsForm aiJIS90Form New properties were added to the Application class build number and locale f...

Страница 14: ...t swatch group 1 of document 1 JavaScript app activeDocument swatchGroups 0 VBScript App ActiveDocument SwatchGroups 1 A new collection SwatchGroups contains all SwatchGroup objects in a document It h...

Страница 15: ...cript RasterizationColorModel GRAYSCALE VBScript AiRasterizationColorModel aiGrayscale A new type AntiAliasingMethod controls the type of rasterization method used in the rasterization none art optimi...

Страница 16: ...he ESTK Scripters need to be very careful about variable initialization and namespace conflict when pushing a batch of Illustrator scripts repeatedly for execution in Illustrator via the ESTK in one I...

Страница 17: ...ng with the application object Note that the layer and group item classes can contain nested objects of the same class which can in turn contain additional nested objects In addition to this applicati...

Страница 18: ...rties 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 Th...

Страница 19: ...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 documen...

Страница 20: ...mple to create a new path item object AppleScript set myPathItem to make new path item in current document JavaScript var myPathItem activeDocument pathItems add VBScript Set myPathItem appRef ActiveD...

Страница 21: ...ge 0 0 to 255 0 for the each of the three individual color values The CMYK color object using the percentage values 0 0 through 100 0 for each of the four individual color values The grayscale color o...

Страница 22: ...ct which is specified using the text frame object s text path property The text path defines the text frame s position and orientation horizontal or vertical on the artboard while the text frame objec...

Страница 23: ...property Text styles Text style elements like font capitalization and justification are represented by paragraph attribute and character attribute objects These attribute objects are properties of th...

Страница 24: ...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 linked to its symbol definition so changing the definition of a symbol up...

Страница 25: ...or details search for interapplication messaging or JavaScript messaging framework in JavaScript Tools Guide VBScript In VBScript there are several ways to create an instance of Illustrator CreateObje...

Страница 26: ...cation appRef Quit Working with objects Getting the frontmost document or layer To refer to the selected document use the application object s current document property in AppleScript or the active do...

Страница 27: ...r path item 1 in layer 1 in document 1 JavaScript To refer to a path items object in a document documents 0 pathItems 1 To refer to a path items object in a layer documents 0 layers 0 pathItems 0 CMYK...

Страница 28: ...object Selecting art items You can select an art object like graph items mesh items raster items and symbol items by setting its selected property to true In AppleScript selected is a property of the...

Страница 29: ...r details see JavaScript Tools Guide Em space units Values that use em units instead of points are measured in thousandths of an em An em is proportional to the current font size For example in a 6 po...

Страница 30: ...efines the lower left corner of the printable region of the document as a fixed point Also each page item object has width and height properties The maximum value allowed for the width or height of a...

Страница 31: ...a script is interacting with an application a dialog brings the execution of the script to a halt until the dialog is dismissed This can be a serious problem in an automation environment where there i...

Страница 32: ...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 th...

Страница 33: ...st 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 contai...

Страница 34: ...trator returns object references by index position or name For example this is a reference to the first path in layer 2 path item 1 of layer 2 of document 1 An object s index position may change when...

Страница 35: ...need to access at a later time as there is no guarantee you are accessing the objects you expect when accessing them by index Obtaining objects from documents and layers This script references an obj...

Страница 36: ...dth 100 set myAreaText to make new text frame in current document with properties kind point text contents Text Frame 1 Threaded frames As in the Illustrator application you can thread area text frame...

Страница 37: ...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 pa...

Страница 38: ...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 t...

Страница 39: ...t corner of the of the rectangle is inset 4 inches 288 points from the bottom of the page and 5 inches 360 points from the left edge of the page The lower left corner of the rectangle is inset 1 inch...

Страница 40: ...s 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 H...

Страница 41: ...at have multiple parameters you may omit optional parameters at the end of the parameter list but you may not omit parameters in the middle of the list If you do not want to specify a particular param...

Страница 42: ...plication object use the app global variable The following two statements appear identical to the JavaScript engine var frontMostDocument activeDocument var frontMostDocument app activeDocument Access...

Страница 43: ...t in the collections using the name surrounded by square brackets for example var getStyle myStyles Ice Type Each element in the collection is an object of the desired type and you can access its prop...

Страница 44: ...me of a specific type in JavaScript use the textFrames method whose name corresponds to the text frame s type for example var rectRef docRef pathItems rectangle 700 50 100 100 use the areaText method...

Страница 45: ...hod of the pathItems object The following script specifies three pairs of x y coordinates to create a path with three points var myDoc app activeDocument var myLine myDoc pathItems add set stroked to...

Страница 46: ...0 320 newPoint2 pointType PointType CORNER Combining path point types The following script sample creates a path with three points var myDoc app activeDocument var myLine myDoc pathItems add myLine st...

Страница 47: ...The left edge is 2 inches 144 points from the left edge of the page The rectangle is 1 inch 72 points wide and 3 inches 216 points long Creating a polygon Consider the following sample var myDocument...

Страница 48: ...y programming language is displaying the message Hello World Follow these steps 1 Start any text editor for example Notepad 2 Type the following code Rem Hello World Set appRef CreateObject Illustrato...

Страница 49: ...Left 0 2 Run the script Accessing and referencing objects When you write a script you must first decide which file or Document the script should act on Through the Application object the script can c...

Страница 50: ...eateObject Illustrator CMYKColor Working with selections When the user makes a selection in a document the selected objects are stored in the document s selection property To access all selected objec...

Страница 51: ...nts Add Set myPathItem1 myDoc PathItems Rectangle 244 64 82 76 Set myTextFrame1 myDoc TextFrames AreaText myPathItem1 myTextFrame1 Contents This is two text frames linked together as one story with te...

Страница 52: ...erty as an array of page coordinates in the format Array x y If all three properties of a PathPoint object have the same coordinates and the properties of the next PathPoint in the line are equal to e...

Страница 53: ...nd other characteristics like the number of sides in a polygon Remember The scripting engine processes all measurements and page coordinates as points For details see Measurement units on page 29 x an...

Страница 54: ...The property uses the aiTextOrientation enumeration which has two possible values aiHorizontal and aiVertical To find the numeral values of enumerations use either of the following The object browser...

Страница 55: ...em positioning 29 printing 32 E em space units 29 enumeration values 54 executing scripts 9 10 ExtendScript file extension 7 F file extensions for valid scripts 7 fixed points 29 fixed rectangles 30 f...

Страница 56: ...out 21 settings options 32 Q Qs unit conversion 29 quitting Illustrator 25 R rectangles creating 53 fixed 30 references object See object references right direction 31 S script examples creating a cur...

Страница 57: ...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 W width maximum value all...

Отзывы: