Adobe 23101764 Scripting Guide - Page 14

Object Model

Page 14 highlights

Scripting basics 2 Object Model JavaScript app.activeDocument.layerSets[0].layers[0]; When you identify an object in this fashion, you're creating an object reference. While AppleScript, Visual Basic and JavaScript use different syntax for object references, each gives the script a way of finding the object you want. 2.3 Object Model To create efficient scripts, you need to understand the containment hierarchy of the object model. Understanding the relationships among objects allows you to construct logical scripts with sound structures that contain fewer bugs and are easier to maintain. In the object model illustrated below, the Photoshop Application object sits at the top of the containment hierarchy. The Document object, directly below the Photoshop application, is the the active object you are working with and the gateway to the main components of the Photoshop object model. Document Class The Document class is used to make modifications to the document image. By using the Document object you can crop, rotate or flip the canvas, resize the image or canvas, and trim the image. You could also use the Document object to get the active layer, for example, save the current document, then copy and paste within the active document or between different documents. For more information on document objects, see Section 3.9 on page 68. Photoshop CS Scripting Guide 10

  • 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
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105

Photoshop CS Scripting Guide
10
Scripting basics
Object Model
2
JavaScript
app.activeDocument.layerSets[0].layers[0];
When you identify an object in this fashion, you’re creating an
object reference
. While
AppleScript, Visual Basic and JavaScript use different syntax for object references, each gives
the script a way of
nding the object you want.
2.3 Object Model
To create ef
cient scripts, you need to understand the containment hierarchy of the object
model. Understanding the relationships among objects allows you to construct logical scripts
with sound structures that contain fewer bugs and are easier to maintain.
In the object model illustrated below, the Photoshop Application object sits at the top of the
containment hierarchy. The Document object, directly below the Photoshop application, is the
the active object you are working with and the gateway to the main components of the
Photoshop object model.
Document Class
The Document class is used to make modi
cations to the document image. By using the
Document
object you can crop, rotate or
ip the canvas, resize the image or canvas, and trim
the image. You could also use the
Document
object to get the active layer, for example, save
the current document, then copy and paste within the active document or between different
documents.
For more information on document objects, see
Section 3.9 on page 68
.