Adobe 65048332 Scripting Guide - Page 11

Photoshop Object Model, Containment hierarchy

Page 11 highlights

CHAPTER 2: Photoshop Scripting Basics Photoshop Object Model 11 Photoshop Object Model A document object model (DOM) is an application programming interface (API), which allows you to programmatically access various components of a document (as defined for that application) through a scripting language. For additional information about Adobe object models and the scripting languages that support them, see Introduction to Scripting. The Photoshop DOM consists of a hierarchical representation of the Photoshop application, the documents used in it, and the components of the documents. The DOM allows you to programmatically access and manipulate the document and its components. For example, through the DOM, you can create a new document, add a layer to an existing document, or change the background color of a layer. Most of the functionality available through the Photoshop user interface is available through the DOM. A good understanding of the Photoshop DOM, and how each aspect of the DOM relates to the Photoshop application and its documents will make script writing easier. Containment hierarchy The Photoshop object model is a containment hierarchy, which means that objects in the model are identified partially by the objects that contain them. In Photoshop, the Application object sits at the top of the hierarchy. Applications contain a Documents collection. The Documents collection contains Document objects. A Document object contains an ArtLayers collection, a HistoryStates collection, a Layers collection, a Layersets collection, and a Channels collection. Through using commands or methods in the DOM, you can tell Photoshop documents to add and remove objects, or set or change individual object properties like color, size and shape. In the diagram below, each node in the hierarchy represents a class in the Photoshop DOM. The Photoshop object model uses elements (AppleScript) or collections (VBScript, JavaScript) as a convenient way to group classes. We have not shown object elements or collections in the object model diagram below. Not all classes are associated with a collection. However, some key classes are grouped by elements or collection. The following elements/collections exist in Photoshop: Art Layers, Channels, Color Samplers, Count Items, Documents, Layers, Layer Comps, Layer Sets, History States, Notifiers, Path Items, Path Points Sub Path Items, and Text Fonts. See Introduction to Scripting for more information on elements and collections. NOTE: In Photoshop, VBScript collections index from 1 rather than 0. This stands in contrast to other VBScript arrays, which index from 0.

  • 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
Photoshop Object Model
11
Photoshop Object Model
A document object model (DOM) is an application programming interface (API), which allows you to
programmatically access various components of a
document
(as defined for that application) through a
scripting language. For additional information about Adobe object models and the scripting languages
that support them, see
Introduction to Scripting
.
The Photoshop DOM consists of a hierarchical representation of the Photoshop application, the
documents used in it, and the components of the documents. The DOM allows you to programmatically
access and manipulate the document and its components. For example, through the DOM, you can create
a new document, add a layer to an existing document, or change the background color of a layer. Most of
the functionality available through the Photoshop user interface is available through the DOM.
A good understanding of the Photoshop DOM, and how each aspect of the DOM relates to the Photoshop
application and its documents will make script writing easier.
Containment hierarchy
The Photoshop object model is a
containment
hierarchy
, which means that objects in the model are
identified partially by the objects that contain them. In Photoshop, the
Application
object sits at the top
of the hierarchy. Applications contain a Documents collection. The Documents collection contains
Document objects. A Document object contains an ArtLayers collection, a HistoryStates collection, a
Layers collection, a Layersets collection, and a Channels collection. Through using commands or methods
in the DOM, you can tell Photoshop documents to add and remove objects, or set or change individual
object properties like color, size and shape. In the diagram below, each node in the hierarchy represents a
class in the Photoshop DOM.
The Photoshop object model uses elements (AppleScript) or collections (VBScript, JavaScript) as a
convenient way to group classes. We have not shown object elements or collections in the object model
diagram below. Not all classes are associated with a collection. However, some key classes are grouped by
elements or collection. The following elements/collections exist in Photoshop:
Art
Layers
,
Channels
,
Color
Samplers
,
Count
Items
,
Documents
,
Layers
,
Layer
Comps
,
Layer
Sets
,
History
States
,
Notifiers
,
Path
Items
,
Path
Points
Sub
Path
Items
, and
Text
Fonts
. See
Introduction to Scripting
for
more information on elements and collections.
N
OTE
:
In Photoshop, VBScript collections index from 1 rather than 0. This stands in contrast to other
VBScript arrays, which index from 0.