Adobe 65010248 Scripting Guide - Page 36

Selecting artwork objects, Working with text frames, Threaded frames

Page 36 highlights

CHAPTER 4: Scripting with AppleScript Working with text frames 36 Depending on what is selected, the selection property value can be an array of any type of art objects. To get or manipulate the properties of the selected art items, you must retrieve the individual items in the array. To find out an object's type, use the class property. The following sample gets the first object in the array, then displays the object's type: tell application "Adobe Illustrator" set myDoc to current document set selectedObjects to selection of myDoc set topObject to item 1 of selectedObjects display dialog (class of topObject) end tell The first object in a selection array is the selected object that was last added to the page, not the last object selected. Selecting artwork objects To select an art object, the object's selected property. Working with text frames To create a text frame of a specific type in AppleScript, use the kind property of the text frame object: set myRect to make new rectangle in current document with properties {position:{100, 700}, height:100, width: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 frames or path text frames. To thread existing text frames, use the next frame or previous frame property of the text frame object. When copying the following script to your script editor, 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 current document with properties {kind:area text, text path:the result, name:"tf1", contents:"This is two text frames linked together as one story, with text flowing from the first to the last. First frame content. "} make new rectangle in current document with properties {position:{300, 700}, height:100, width:100} make new text frame in current document with properties {kind:area text, text path:the result, name:"tf2", contents:"Second frame content." } --use the next frame property to thread the frames set next frame of text frame "tf1" of current document to text frame "tf2" of current document redraw end tell

  • 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

C
HAPTER
4: Scripting with AppleScript
Working with text frames
36
Depending on what is selected, the
selection
property value can be an array of any type of art objects.
To get or manipulate the properties of the selected art items, you must retrieve the individual items in the
array. To find out an object’s type, use the
class
property.
The following sample gets the first object in the array, then displays the object’s type:
tell application "Adobe Illustrator"
set myDoc to current document
set selectedObjects to selection of myDoc
set topObject to item 1 of selectedObjects
display dialog (class of topObject)
end tell
The first object in a selection array is the selected object that was last
added
to the page, not the last object
selected.
Selecting artwork objects
To select an art object, the object’s
selected
property.
Working with text frames
To create a text frame of a specific type in AppleScript, use the
kind
property of the
text
frame
object:
set myRect to make new rectangle in current document with properties
{position:{100, 700}, height:100, width: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 frames or path text frames.
To thread existing text frames, use the
next
frame
or
previous
frame
property of the
text
frame
object.
When copying the following script to your script editor, 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 current document with properties
{kind:area text, text path:the result, name:"tf1",
contents:"This is two text frames linked together as one story, with
text flowing from the first to the last. First frame content. "}
make new rectangle in current document with properties
{position:{300, 700}, height:100, width:100}
make new text frame in current document with properties
{kind:area text, text path:the result, name:"tf2",
contents:"Second frame content." }
--use the next frame property to thread the frames
set next frame of text frame "tf1" of current document to
text frame "tf2" of current document
redraw
end tell