Adobe 23102480 Scripting Guide - Page 61

To work with document preferences, Preference, Set to, What it does

Page 61 highlights

Adobe Photoshop CS3 Scripting Guide Photoshop CS3 Scripting Photoshop CS3 61 Preference rulers units dialog modes Set to inches pixels never What it does Uses inches as the unit of measurement for graphics. Uses pixels as the unit of measurement for text (type). Suppresses the use of dialogs so that your script executes without the user being asked for input (such as clicking an OK button) at various stages of the process. Note: dialog modes is not an option in the Photoshop CS3 application. Next, the script declares variables that store document dimensions in inches and document resolution in pixels. The script then declares a display resolution, and assigns the text "Hello, World!" to a string variable. Next, an if statement checks whether a Document object has been created and then creates a new Document object if none exists. Finally, the script restores the original preferences. AS ➤ To work with document preferences: 1. Create and run the following script. See 'Creating and Running an AppleScript' on page 15 for details. tell application "Adobe Photoshop CS3" --make Photoshop CS3 the active (front-most) application activate --create variables for the default settings set theStartRulerUnits to ruler units of settings set theStartTypeUnits to type units of settings set theStartDisplayDialogs to display dialogs --change the settings set ruler units of settings to inch units set type units of settings to pixel units set display dialogs to never --create variables for default document settings set theDocWidthInInches to 4 set theDocHeightInInches to 2 set theDocResolution to 72 set theDocString to "Hello, World!" --check to see whether any documents are open --if none are found, create a document --use the default document settings as its properties if (count of documents) is 0 then make new document with properties ¬ {width:theDocWidthInInches, height:theDocHeightInInches,¬ resolution:theDocResolution, name:theDocString} end if --change the settings back to the original units stored in the variables set ruler units of settings to theStartRulerUnits set type units of settings to theStartTypeUnits

  • 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
61
Next, the script declares variables that store document dimensions in inches and document resolution in
pixels. The script then declares a display resolution, and assigns the text "Hello, World!" to a string variable.
Next, an
if
statement checks whether a
Document
object has been created and then creates a new
Document
object if none exists.
Finally, the script restores the original preferences.
AS
To work with document preferences:
1.
Create and run the following script. See
‘Creating and Running an AppleScript’ on page 15
for details.
tell application "Adobe Photoshop CS3"
--make Photoshop CS3 the active (front-most) application
activate
--create variables for the default settings
set theStartRulerUnits to ruler units of settings
set theStartTypeUnits to type units of settings
set theStartDisplayDialogs to display dialogs
--change the settings
set ruler units of settings to inch units
set type units of settings to pixel units
set display dialogs to never
--create variables for default document settings
set theDocWidthInInches to 4
set theDocHeightInInches to 2
set theDocResolution to 72
set theDocString to "Hello, World!"
--check to see whether any documents are open
--if none are found, create a document
--use the default document settings as its properties
if (count of documents) is 0 then
make new document with properties ¬
{width:theDocWidthInInches, height:theDocHeightInInches,¬
resolution:theDocResolution, name:theDocString}
end if
--change the settings back to the original units stored in the variables
set ruler units of settings to theStartRulerUnits
set type units of settings to theStartTypeUnits
Preference
Set to
What it does
rulers
inches
Uses inches as the unit of measurement for graphics.
units
pixels
Uses pixels as the unit of measurement for text (type).
dialog modes
never
Suppresses the use of dialogs so that your script executes without
the user being asked for input (such as clicking an OK button) at
various stages of the process.
Note:
dialog modes is not an option in the Photoshop CS3
application.