Setting The Active Object - Adobe 23102480 - Photoshop CS3 - PC Programming Manual

Scripting guide
Table of Contents

Advertisement

Adobe Photoshop CS3 Scripting Guide
JS
In JavaScript, you can use the
with objects other than collection objects.
Similar to VBScript, the JavaScript statement to create a document is:
documents.add()
and not:
document.add()
Note:
You can include an
to the previous sample:
To add an
add() method for the ArtLayers collection, using the artLayers property of Document.
documents[0].artLayers.add()
As with VBScript, the
Document
does.
Note:
The
Layers

Setting the Active Object

To work on a an object in the Photoshop CS3 application, you must make the object the front-most, or
active object. For example, to work in a layer, you must first bring the layer to the front.
In scripting, the same rule applies. If your script creates two or more documents, the commands and
methods in your script are executed on the active document. Therefore, to ensure that your commands are
acting on the correct document, it is good programming practice to designate the active document
before executing any commands or methods in the script.
To set an active object, do the following:
In AppleScript, you use the
In VBScript, you use the
ActiveLayer
In JavaScript, you use the
activeLayer
Note:
The parent object is the object that contains the specified object. For example, the application is the
parent of the document; a document is the parent of a layer, selection, or channel.
For example, if you look at the
Reference, or in the ExtendScript Object Model Viewer, you find one of its properties is
activeDocument
activeHistoryState
CS3 AppleScript Scripting Reference, or in thePhotoshop CS3 AppleScript Dictionary, you find it has
the property of
For sample scripts that set active objects, see the following sections.
'Setting the Active Document' on page 24
'Setting the Active Layer' on page 25
'Setting the Active Channels' on page 25
add()
Application
app.documents.add()
object, you must reference the
ArtLayer
method is associated with the JavaScript
add()
object. Similarly, the
ArtLayer
collection object does not include an
Layers
object in the Adobe Photoshop CS3 JavaScript Scripting Reference.
current
Active
).
active
).
; if you look at the
as properties. Similarly, if you look at
, and so on.
current
Photoshop CS3
method only with the collection name. The
object reference if you wish. The following statement is equivalent
Document
object does not have an
add()
property of the parent object.
property of the parent object (such as
Object
property of the parent object (such as
Object
object in the Adobe Photoshop CS3 JavaScript Scripting
Application
object, you will find
Document
Scripting Photoshop CS3
add()
object that contains the layer, and use the
object but not with the
Documents
method; the
add()
method. For more information, look up the
ActiveDocument
activeDocument
activeLayer
in the Adobe Photoshop
application
23
method is not valid
object
ArtLayers
or
or
and

Advertisement

Table of Contents
loading

This manual is also suitable for:

13102498 - photoshop cs3 - macPhotoshop cs3

Table of Contents