Photoshop CS2
Adobe Photoshop CS2 Scripting Guide
Scripting basics 23
Note:
The lines preceded by “--” are comments. Entering the comments is optional.
-- Sample script to create a new text item and
-- change its contents.
--target Photoshop CS2
tell application "Adobe Photoshop CS2"
-- Create a new document and art layer.
set docRef to make new document with properties ¬
{width:3 as inches, height:2 as inches}
set artLayerRef to make new art layer in docRef
-- Change the art layer to be a text layer.
set kind of artLayerRef to text layer
-- Get a reference to the text object and set its contents.
set contents of text object of artLayerRef to "Hello, World"
end tell
2. Click
Run
to run the script. Photoshop CS2 creates a new document, adds a new layer, changes the
layer’s type to text and sets the text to “Hello, World”
Note:
If you encounter errors, see
‘AppleScript Debugging’ on page 32
Creating and Running a VBScript
Follow these steps to create and run a VBScript that displays the text
Hello World!
in a Photoshop CS2
document.
➤
To create and run your first Photoshop CS2 VBScript:
1. Type the following script into a script or text editor.
Note:
Entering comments is optional.
Dim appRef
Set appRef = CreateObject( "Photoshop.Application" )
' Remember current unit settings and then set units to
' the value expected by this script
Dim originalRulerUnits
originalRulerUnits = appRef.Preferences.RulerUnits
appRef.Preferences.RulerUnits = 2
' Create a new 4x4 inch document and assign it to a variable.
Dim docRef
Dim artLayerRef
Dim textItemRef
Set docRef = appRef.Documents.Add(4, 4)
' Create a new art layer containing text
Set artLayerRef = docRef.ArtLayers.Add
artLayerRef.Kind = 2
' Set the contents of the text layer.
Set textItemRef = artLayerRef.TextItem
textItemRef.Contents = "Hello, World!"
' Restore unit setting
appRef.Preferences.RulerUnits = originalRulerUnits
Содержание PHOTOSHOP CS 2.0 - SCRIPTING GUIDE
Страница 1: ...bbc Adobe Photoshop cs 2 Scripting Guide ...