Adobe PHOTOSHOP CS 2.0 - SCRIPTING GUIDE Manual page 55

Table of Contents

Advertisement

Adobe Photoshop CS2 Scripting Guide
The following examples show how to create a
object in the current document:
AS
tell application "Adobe Photoshop CS2"
make new layer set after layer 1 of current document
end tell
VBS
Dim appRef
Set appRef = CreateObject("Photoshop.Application")
' Get a reference to the first layer in the document
Dim layerRef
Set layerRef = appRef.ActiveDocument.Layers(1)
' Create a new LayerSet (it will be created at the beginning of the ' document)
Dim newLayerSetRef
Set newLayerSetRef = appRef.ActiveDocument.LayerSets.Add
' Move the new layer to after the first layer
newLayerSetRef.Move layerRef, psPlaceAfter
JS
// Get a reference to the first layer in the document
var layerRef = app.activeDocument.layers[0]
// Create a new LayerSet (it will be created at the beginning of the // document)
var newLayerSetRef = app.activeDocument.layerSets.add()
// Move the new layer to after the first layer
newLayerSetRef.move(layerRef, ElementPlacement.PLACEAFTER)
Referencing ArtLayer Objects
When you create a layer in the Photoshop CS2 application (rather than a script), the layer is added to the
Layers palette and given a number. These numbers act as layer names and do not correspond to the index
numbers of
Your VBScript script or JavaScript will always consider the layer at the top of the list in the Layers palette as
the first layer in the index. For example, if your document has four layers, the Photoshop CS2 application
names them Background Layer, Layer 1, Layer 2, and Layer 3. Normally, Layer 3 would be at the top of the
list in the Layers palette because you added it last. If your script is working on this open document and
uses the syntax
will be selected. If you then you drag the Background layer to the top of the list in the Layers palette and
run the script again, the Background layer is selected.
You can use the following syntax to refer to the layers by the names given them by the Application:
AS
layer 1 of layer set 1 of current document
objects you create in a script.
ArtLayer
Layers(0).Select/layers[0].select()
Photoshop CS2
object after the creating the first
Layer Set
to tell Photoshop CS2 to select a layer, Layer 3
Scripting Photoshop CS2
ArtLayer
51

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the PHOTOSHOP CS 2.0 - SCRIPTING GUIDE and is the answer not in the manual?

This manual is also suitable for:

Photoshop cs2

Table of Contents