Photoshop CS2
Adobe Photoshop CS2 Scripting Guide
Scripting Photoshop CS2 38
New
icon on the appropriate palette. This section demonstrates how to accomplish these same tasks in a
script.
To create an object in a script, you name the type of object you want to create and then use the following
command/method:
●
AS:
make
●
VBS:
Add
●
JS:
add()
As you can see in the Photoshop CS2 Object Model, the Document object contains all other objects except
the Application object. Therefore, you must reference the
Document
object when adding objects other
than
Document
objects to your script.
Note:
In VBScript and JavaScript, you use the object’s collection name to name the object type. For
example, you add a document to the
Documents
collection; you add an art layer to the
art layers
collection. See
‘Object Elements and Collections’ on page 9
for more information.
AS
The following statement creates a
Document
object in an AppleScript.
make new document
You can also use the
set
command to create a variable to hold a reference to a new document. In the
following example, the variable named
docRef
holds a reference to the new document:
set docRef to make new document
To create an object other than a document, you must reference the
Document
object that contains the
object. The following sample creates an art layer in the document contained in the variable named
docRef
.
make new art layer in docRef
Note:
When you create object in AppleScript, you actually add the object to an element the same way you
add a VBScript or JavaScript object to a collection. However, in AppleScript, the element name is
implied in the
make
or
set
statement. For example, the statement:
make new document
actually means:
make new document in the documents element
Do the following to find out more about creating objects in an AppleScript:
●
Look up the
make
and
set
commands in the “Commands” chapter in the
Adobe Photoshop CS2
AppleScript Scripting Reference
.
●
To find out which commands can be used with an object, look up the object or the object’s element
name in the “Objects” chapter in the
Adobe Photoshop CS2 AppleScript Scripting Reference
and check the
Valid Commands list. For example, look up “document” or “documents” to learn which commands can
be used with
Document
objects.
VBS
In VBScript, you can use the
Add
method
only
with the collection name. The
Add
method is not valid with
objects other than collection objects. Also, in VBScript, you must reference the
Application
object when
creating when creating, or referring to, an object in your script.
For example, to create a document in a VBScript script, you
cannot
use the object name, as in the following
sample, which creates a
Document
object:
appRef.Document.Add()
Содержание PHOTOSHOP CS 2.0 - SCRIPTING GUIDE
Страница 1: ...bbc Adobe Photoshop cs 2 Scripting Guide ...