Adobe photoshop cs 2.0 User Guide

Page of 91
Photoshop CS2
Adobe Photoshop CS2  Scripting Guide
 Scripting Photoshop CS2     55
JS
if (newLayerRef.kind == LayerKind.TEXT)
Adding and Manipulating Text in a Text Item Object
The following examples add and right-justify text in a text layer.
AS
set contents of text object of art layer "my text" to "Hello, World!"
set justification of text object of art layer "my text" of ¬
current document to right
VBS
Set textItemRef = artLayers("my text").TextItem
textItemRef.Contents = "Hello, World!"
docRef.ArtLayers("my text").TextItemRef.Justification = 3
'3 = psRight (for the constant value psJustification)
JS
var textItemRef = artLayers["my text"].textItem
textItemRef.contents = "Hello, World!"
docRef.artLayers["my text"].textItemRef.justification =
Justification.RIGHT
Note:
The 
text item
 object has a 
kind
 property, which can be set to either 
point text 
/psPointText/TextType.POINTTEXT
/ or 
paragraph 
text/psParagraphText/TextType.PARAGRAPHTEXT
. When a new 
text item 
is created, its 
kind
 
property is automatically set to 
point text
.
The 
text item
 properties 
height, width
 and 
leading
 are valid only when the text item's 
kind
 
property is set to 
paragraph text.
To familiarize yourself with this objects, properties, and commands/methods in the scripting references, 
do the following:
In the Adobe Photoshop CS2 AppleScript Scripting Reference, look up the 
Class text-object
 
properties and methods. 
In the Adobe Photoshop CS2 Visual Basic Scripting Reference and the Adobe Photoshop CS2 JavaScript 
Scripting Reference
, look up the 
TextItem
 property of the 
ArtLayer
 object. To find the properties 
and methods you can use with a text layer, look up the 
TextItem
 object. 
Working with Selection Objects
You create a 
Selection
 object to allow your scripts to act only on a specific, selected section of your 
document or a layer within a document. For example, you can apply effects to a selection or copy the 
current selection to the clipboard. 
The 
Selection
 object is a property of the 
Document
 object. Look up the following for more information:
In the Adobe Photoshop CS2 AppleScript Scripting Reference, look up 
select
 in the “Commands” chapter. 
Also, look up the 
selection
 property of the 
Class Document
 object and the 
Class 
selection-object
.