Adobe 23101764 - Photoshop CS - PC Manual page 13

Scripting guide
Hide thumbs Also See for 23101764 - Photoshop CS - PC:
Table of Contents

Advertisement

2.2.2 Object inheritance
Object classes may also "inherit," or share, the properties of a parent, or superclass. When a
class inherits properties, we call that class a child, or subclass of the class from which it
inherits properties. So in our house example, windows and doors are subclasses of an openings
class, since they are both openings in a house. In Photoshop, art layers, for example, inherit
from the layer class.
Classes often have properties that aren't shared with their superclass. Both a window and a
door, for example, inherit an "opened" property from the opening class, but a window has a
"number of panes" property which the Opening class does not. In Photoshop, art layers, for
example, have the property "grouped" which is not inherited from the Layer class.
2.2.3 Object elements or collections
Object elements (AppleScript) or collections (Visual Basic, JavaScript) are objects contained
within other objects. For example, rooms are elements (or collections) of our house, contained
within the house object. In Photoshop, documents are elements of the application object, and
layers are elements of a document object. To access an element (or member of a collection),
you use an index. For example, to get the first document of the application you write:
AS: document 1
VB: appRef.Documents (1)
JS: app.documents[0];
IMPORTANT:
2.2.4 Object reference
The objects in Photoshop documents are arranged in a hierarchy like the house object —
layers are contained within layer sets, which are placed inside a document which exists within
the Photoshop application. When you send a command to a Photoshop object, you need to
make sure you send the message to the right object. To do this, you identify objects by their
position in the hierarchy — by an object reference. You might, for example, write the
following statement.
AppleScript
layer 1 of layer set 1 of current document
Visual Basic
appRef.ActiveDocument.LayerSets(1).Layers(1)
Photoshop CS Scripting Guide
Indices in AppleScript and Visual Basic are 1 based. JavaScript indices are 0
based.
Scripting basics
Object model concepts
2
9

Advertisement

Table of Contents
loading

This manual is also suitable for:

Photoshop cs

Table of Contents