Photoshop CS2
Adobe Photoshop CS2 Scripting Guide
Scripting Photoshop CS2 39
You must use the collection name, which is a plural form of the object name, as follows:
appRef.Documents.Add()
Note:
In this sample statement, the
Application
object is referenced via a variable named
appRef
. See
‘Targeting and Referencing the Application Object’ on page 37
for more information.
To add an
ArtLayer
object, you must reference both the
Application
and
Document
objects that will
contain the art layer. The following sample references the
Application
object using the variable
appRef
and the
Document
object using the documents index rather than the
Document
object’s name.
appRef.Documents(0).ArtLayers.Add()
If you look up in the
Document
object in the
Adobe Photoshop CS2 Visual Basic Scripting Reference
, you will
see that there is no
Add()
method in the object’s Methods table. However, the
Add()
method is available
for the
Documents
object. Similarly, the
ArtLayer
object does not have an
Add()
method; the
ArtLayers
object does.
Note:
The
Layers
object is an exception because, although it is a collection object, it does not include an
Add()
method. The
Layers
collection includes both
ArtLayer
and
LayerSet
objects. For more
information, look up the
Layers
object in the scripting reference.
JS
In JavaScript, you can use the
add()
method only with the collection name. The
add()
method is not valid
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
Application
object reference if you wish. The following statement is equivalent
to the previous sample:
app.documents.add()
To add an
ArtLayer
object, you must reference the
Document
object that will contain the layer.
documents(0).artLayers.add()
The
add()
method is associated with the JavaScript
Documents
object but not with the
Document
object
(refer to the
Adobe Photoshop CS2 JavaScript Scripting Reference
).
Similarly, the
ArtLayer
object does not have an
add()
method; the
ArtLayers
object does.
Note:
The
Layers
collection object does not include an
add()
method. For more information, look up the
Layers
object in the
Adobe Photoshop CS2 JavaScript Scripting Reference
.
Setting the Active Object
To work on a an object in the Photoshop CS2 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
current
property of the parent object.
Содержание PHOTOSHOP CS 2.0 - SCRIPTING GUIDE
Страница 1: ...bbc Adobe Photoshop cs 2 Scripting Guide ...