Visual Basic And Javascript - Adobe 23101764 - Photoshop CS - PC Manual

Scripting guide
Hide thumbs Also See for 23101764 - Photoshop CS - PC:
Table of Contents

Advertisement

3.
4.
5.
6.
7.
end tell
This script will not set the name of the layer referenced on the fourth line of the script. Instead
it will set the name created on line five. Try referencing the objects by name as shown below:
1.
tell application "Adobe Photoshop CS"
2.
3.
4.
5.
6.
7.
end tell

3.5.2 Visual Basic and JavaScript

Object references in Visual Basic and JavaScript are fixed and remain valid until disposed or
until the host object goes away.
The following example shows how to create 2 layers and then rename the first one in Visual
Basic.
Dim appRef As Photoshop.Application
Dim docRef As Photoshop.Document
Dim layer1Ref As Photoshop.ArtLayer
Dim layer2Ref As Photoshop.ArtLayer
' Set ruler units and create a new document.
Set appRef = New Photoshop.Application
originalRulerUnits = appRef.Preferences.RulerUnits
appRef.Preferences.RulerUnits = psInches
Set docRef = appRef.Documents.Add(4, 4, 72, "My New Document")
' Create 2 new layers and store their return references.
Set layer1Ref = docRef.ArtLayers.Add()
Set layer2Ref = docRef.ArtLayers.Add()
' Change the name of the first layer that was created.
layer1Ref.Name = "This layer was first"
'restore unit values
appRef.Preferences.RulerUnits = originalRulerUnits
Photoshop CS Scripting Guide
set newDocument to make new document with properties ¬
{ width: inches 2, height: inches 3}
set layerRef to layer 1 of current document
make new art layer in current document
set name of layerRef to "My layer"
activate
set newDocument to make new document with properties ¬
{ width: inches 2, height: inches 3}
make new art layer in current document with properties {name: "L1" }
make new art layer in current document with properties {name: "L2" }
set name of art layer "L1" of current document to "New Layer 1"
Scripting Photoshop
Object references
3
56

Advertisement

Table of Contents
loading

This manual is also suitable for:

Photoshop cs

Table of Contents