Adobe Smoke Alarm CS3 Manuale Utente

Pagina di 85
Photoshop CS3
Adobe Photoshop CS3  Scripting Guide
 Scripting Photoshop CS3     22
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 Adobe Photoshop CS3 AppleScript Scripting Reference or in 
the Photoshop CS3 AppleScript Dictionary. Se
.
To find out which commands can be used with an object, look up the object in the Adobe Photoshop 
CS3 AppleScript Scripting Reference
. If an object has valid commands, there will be a “Valid Commands” 
list at the end of the object description. 
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()
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 
 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 document’s index rather than the documents name.
appRef.Documents(1).ArtLayers.Add()
Caution:
In Photoshop, VBScript collections index from 1 rather than 0. That is to say, the first document 
created has index 1, rather than index 0.
If you look up in the 
Document
 object in the Adobe Photoshop CS3 Visual Basic Scripting Reference or in the 
Visual Basic Object Browser, you will see that there is no 
Add()
 method for the object. 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, which are 
created with the 
Add
 method on either the 
ArtLayers
 or 
LayerSets
 collections. For more 
information, look up the 
Layers
 object in theAdobe Photoshop CS3 Visual Basic Scripting Reference