Adobe 65014293 Scripting Guide - Page 17

Creating a sample Hello World script - illustrator

Page 17 highlights

CHAPTER 2: Photoshop Scripting Basics Creating a sample Hello World script 17 Creating a sample Hello World script This section demonstrates a very simple script in each of the three scripting languages for Photoshop. Traditionally, the first thing to accomplish in any programming environment is the display of a "Hello World" message. Our Hello World scripts will do the following: 1. Open the Photoshop application. 2. Create a new Document object. When we create the document, we will also create a variable named docRef and then assign a reference to the document as the value of docRef. The document will be 4 inches wide and 2 inches high. 3. Create an Art Layer object. In our script, we will create a variable named artLayerRef and then assign a reference to the Art Layer object as the value of artLayerRef. 4. Define artLayerRef as a text item. 5. Set the contents of the text item to "Hello World". NOTE: We will also include comments throughout the scripts. In fact, because this is our first script, we will use comments to excess. These steps mirror a specific path in the containment hierarchy, as illustrated below. Application Document Art Layer Text Item

  • 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
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87

C
HAPTER
2: Photoshop Scripting Basics
Creating a sample Hello World script
17
Creating a sample Hello World script
This section demonstrates a very simple script in each of the three scripting languages for Photoshop.
Traditionally, the first thing to accomplish in any programming environment is the display of a "Hello
World" message.
Our Hello World scripts will do the following:
1.
Open the Photoshop application.
2.
Create a new
Document
object.
When we create the document, we will also create a variable named
docRef
and then assign a
reference to the document as the value of
docRef
. The document will be 4 inches wide and 2 inches
high.
3.
Create an
Art
Layer
object.
In our script, we will create a variable named
artLayerRef
and then assign a reference to the
ArtLayer
object as the value of
artLayerRef
.
4.
Define
artLayerRef
as a text item.
5.
Set the contents of the text item to "Hello World".
N
OTE
:
We will also include comments throughout the scripts. In fact, because this is our first script, we will
use comments to excess.
These steps mirror a specific path in the containment hierarchy, as illustrated below.
Application
Document
Art Layer
Text Item