Adobe 23102480 Scripting Guide - Page 64

To create and specify details in a text item, Adobe Photoshop CS3 AppleScript Scripting Reference

Page 64 highlights

Adobe Photoshop CS3 Scripting Guide Photoshop CS3 Scripting Photoshop CS3 64 AS ➤ To create and specify details in a text item: 1. Type the following code into the HelloWorldDoc script immediately before the statements at the end of the file that restore original preferences. --create a variable named theDocRef --assign the current (active) document to it set theDocRef to the current document --create a variable that contains a color object of the RGB color class --whose color is red set theTextColor to {class:RGB color, red:255, green:0, blue:0} --create a variable for the text layer, create the layer as an art layer object --and use the kind property of the art layer object to make it a text layer set theTextLayer to make new art layer in theDocRef with ¬ properties {kind:text layer} --Set the contents, size, position and color of the text layer set contents of text object of theTextLayer to "Hello, World!" set size of text object of theTextLayer to 36 set position of text object of theTextLayer to {0.75 as inches, 1 as inches} set stroke color of text object of theTextLayer to theTextColor 2. Run the complete script. Be patient while Photoshop CS3 executes your commands one by one. 3. After viewing the document in Photoshop CS3, close the document without saving it. Note: Look up the following classes in the Adobe Photoshop CS3 AppleScript Scripting Reference or in the Photoshop CS3 AppleScript Dictionary to see if you understand how you used them in this script: ● RGB color class ● art layer class VBS ➤ To create and specify details in a text item: 1. Type the following code into the HelloWorldDoc script immediately before the statements at the end of the file that restore original preferences. 'create a reference to the active (current) document Set docRef = appRef.ActiveDocument ' create a variable named textColor 'create a SolidColor object whose color is red 'assign the object to textColor Set textColor = CreateObject ("Photoshop.SolidColor") textColor.RGB.Red = 255 textColor.RGB.Green = 0 textColor.RGB.Blue = 0 'create an art layer object using the 'Add method of the ArtLayers class 'assign the layer to the variable newTextLayer Set newTextLayer = docRef.ArtLayers.Add()

  • 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

Photoshop CS3
Adobe Photoshop CS3
Scripting Guide
Scripting Photoshop CS3
64
AS
To create and specify details in a text item:
1.
Type the following code into the
HelloWorldDoc
script immediately before the statements at the end
of the file that restore original preferences.
--create a variable named theDocRef
--assign the current (active) document to it
set theDocRef to the current document
--create a variable that contains a color object of the RGB color class
--whose color is red
set theTextColor to {class:RGB color, red:255, green:0, blue:0}
--create a variable for the text layer, create the layer as an art layer object
--and use the kind property of the art layer object to make it a text layer
set theTextLayer to make new art layer in theDocRef with ¬
properties {kind:text layer}
--Set the contents, size, position and color of the text layer
set contents of text object of theTextLayer to "Hello, World!"
set size of text object of theTextLayer to 36
set position of text object of theTextLayer to {0.75 as inches, 1 as inches}
set stroke color of text object of theTextLayer to theTextColor
2.
Run the complete script. Be patient while Photoshop CS3 executes your commands one by one.
3.
After viewing the document in Photoshop CS3, close the document without saving it.
Note:
Look up the following classes in the
Adobe Photoshop CS3 AppleScript Scripting Reference
or in the
Photoshop CS3 AppleScript Dictionary to see if you understand how you used them in this script:
RGB color
class
art layer
class
VBS
To create and specify details in a text item:
1.
Type the following code into the
HelloWorldDoc
script immediately before the statements at the end
of the file that restore original preferences.
'create a reference to the active (current) document
Set docRef = appRef.ActiveDocument
' create a variable named textColor
'create a SolidColor object whose color is red
'assign the object to textColor
Set textColor = CreateObject ("Photoshop.SolidColor")
textColor.RGB.Red = 255
textColor.RGB.Green = 0
textColor.RGB.Blue = 0
'create an art layer object using the
'Add method of the ArtLayers class
'assign the layer to the variable newTextLayer
Set newTextLayer = docRef.ArtLayers.Add()