C
HAPTER
3: Scripting Photoshop
Setting the Active Object
27
JS
// Create 2 documents
var docRef = app.documents.add( 4, 4)
var otherDocRef = app.documents.add (4,6)
//make docRef the active document
app
.
activeDocument = docRef
//here you would include command statements
//that perform actions on the active document. Then, you could
//make a different document the active document
//use the activeDocument property of the Application object to
//bring otherDocRef front-most as the new active document
app
.
activeDocument = otherDocRef
Setting the active layer
The following examples demonstrate how to use the
current
layer (ActiveLayer/activeLayer)
property of the
Document
object to set the active layer. In order to set the active layer for a document, the
document itself must be the current document.
AS
set current layer of current document to layer “Layer 1” of current document
N
OTE
:
By default, Photoshop names the layers “Layer 1”, “Layer2”, etc.
VBS
‘ This example assumes appRef and docRef have been previously defined and assigned
‘ to the application object and a document object that contains at least one layer.
appRef.ActiveDocument = docRef
docRef.ActiveLayer = docRef.Layers(1)
Look up the
ActiveLayer
property on the
Document
object in the
Adobe Photoshop CS4 Visual Basic
Scripting Reference
, or in the Visual Basic Object Browser.
N
OTE
:
You can also use the name of the layer to indicate which layer to use. By default, Photoshop names
the layers “Layer 1”, “Layer2”. See
“Referencing ArtLayer objects” on page 38
.
JS
// This example assumes docRef has been previously defined and assigned to a
// document object that contains at least one layer.
activeDocument = docRef
docRef.activeLayer = docRef.layers[0]
Look up the
activeLayer
property on the
Document
object in the
Adobe Photoshop CS4 JavaScript
Scripting Reference
, or in the ExtendScript Object Model Viewer.
N
OTE
:
You can also use the name of the layer to indicate which layer to use. By default, Photoshop names
the layers “Layer 1”, “Layer2”. See
“Referencing ArtLayer objects” on page 38
.
Содержание 65014293 - Photoshop CS4 - Mac
Страница 1: ...SCRIPTING GUIDE ADOBE PHOTOSHOP CS4 ...