Adobe 65015634 Scripting Guide - Page 41

Using the Text Item object, Determining a layer’s kind

Page 41 highlights

CHAPTER 3: Scripting Photoshop Working with the Photoshop Object Model 41 Using the Text Item object You can change an existing ArtLayer object to a text layer, that is, a Text Item object, if the layer is empty. Conversely you can change a Text Item object to an ArtLayer object. This "reverse" procedure rasterizes the text in the layer object. The Text Item object is a property of the ArtLayer object. However, to create a new text layer, you must create a new ArtLayer object and then set the art layer's kind/Kind/kind property to text layer (2 (psTextLayer)/ LayerKind.TEXT). To set or manipulate text in a text layer, you use the text-object (TextItem/TextItem) object, which is contained in the text object/TextItem/textItem property of the ArtLayer object. Creating a Text Item object The following examples create an ArtLayer object and then use the kind property to convert it to a text layer. AS make new art layer in current document with properties { kind: text layer } VBS set newLayerRef = docRef.ArtLayers.Add() newLayerRef.Kind = 2 '2 indicates psTextLayer JS var newLayerRef = docRef.artLayers.add() newLayerRef.kind = LayerKind.TEXT See "Photoshop Object Model" on page 11 for information on the relationship between ArtLayer objects and TextItem objects. Also, look up the following: ➤ The Kind/kind and TextItem/textItem properties of the ArtLayer object in the Adobe Photoshop CS4 Visual Basic Scripting Reference, Adobe Photoshop CS4 JavaScript Scripting Reference, or in the Visual Basic Object Browser and the ExtendScript Object Model Viewer. ➤ The kind and text object properties of the class art layer in the Adobe Photoshop CS4 AppleScript Scripting Reference or in the Photoshop AppleScript Dictionary. Determining a layer's kind The following examples use an if statement to check whether an existing layer is a text layer. AS if (kind of layerRef is text layer) then ... endif VBS If layerRef.Kind = 2 Then '2 indicates psTextLayer ... End If JS if (newLayerRef.kind == LayerKind.TEXT) {...}

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87

C
HAPTER
3: Scripting Photoshop
Working with the Photoshop Object Model
41
Using the Text Item object
You can change an existing
ArtLayer
object to a text layer, that is, a
Text
Item
object, if the layer is
empty. Conversely you can change a
Text
Item
object to an
ArtLayer
object. This “reverse” procedure
rasterizes the text in the layer object.
The
Text
Item
object is a property of the
ArtLayer
object. However, to create a new text layer, you must
create a new
ArtLayer
object and then set the art layer's
kind/Kind/kind
property to
text
layer
(2
(psTextLayer)/
LayerKind.TEXT
).
To set or manipulate text in a text layer, you use the
text-object
(TextItem/TextItem)
object, which is
contained in the
text
object/TextItem/textItem
property of the
ArtLayer
object.
Creating a Text Item object
The following examples create an
ArtLayer
object and then use the
kind
property to convert it to a text
layer.
AS
make new art layer in current document with properties { kind: text layer }
VBS
set newLayerRef = docRef.ArtLayers.Add()
newLayerRef.Kind = 2
'2 indicates psTextLayer
JS
var newLayerRef = docRef.artLayers.add()
newLayerRef.kind = LayerKind.TEXT
See
“Photoshop Object Model” on page 11
for information on the relationship between
ArtLayer
objects
and
TextItem
objects.
Also, look up the following:
The
Kind/kind
and
TextItem/textItem
properties of the
ArtLayer
object in the
Adobe Photoshop
CS4 Visual Basic Scripting Reference
,
Adobe Photoshop CS4 JavaScript Scripting Reference
, or in the Visual
Basic Object Browser and the ExtendScript Object Model Viewer.
The
kind
and
text
object
properties of the class
art
layer
in the
Adobe Photoshop CS4 AppleScript
Scripting Reference
or in the Photoshop AppleScript Dictionary.
Determining a layer’s kind
The following examples use an
if
statement to check whether an existing layer is a text layer.
AS
if (kind of layerRef is text layer) then
...
endif
VBS
If layerRef.Kind = 2 Then '2 indicates psTextLayer
...
End If
JS
if (newLayerRef.kind == LayerKind.TEXT)
{...}