Adobe 23102480 Scripting Guide - Page 56

Unit Values, Special Unit Value Types, AppleScript Unit Considerations

Page 56 highlights

Adobe Photoshop CS3 Scripting Guide Photoshop CS3 Scripting Photoshop CS3 56 ● A type ruler, which is active when using the type tool. You set measurement unit types for the type ruler using the type units (TypeUnits/typeUnits) property. Note: These settings correspond to those found in the Photoshop CS3 preference dialog under Photoshop > Preferences > Units & Rulers on Mac OS or Edit > Preferences > Units & Rulers in Windows. Unit Values All languages support plain numbers for unit values. These values are treated as being of the type currently specified for the appropriate ruler. For example, if the ruler units are currently set to inches and the following VBScript statement sets a document's size to 3 inches by 3 inches: docRef.ResizeImage 3,3 If the ruler units had been set to pixels, the document would be 3 pixels by 3 pixels. To ensure that your scripts produce the expected results you should check and set the ruler units to the type appropriate for your script. After executing a script the original values of the ruler settings should be restored if changed in the script. See 'Setting Ruler and Type Units in a Script' on page 59 for directions on setting unit values. Please refer to Photoshop CS3 Help for information about available unit value types. Special Unit Value Types The unit values used by Photoshop CS3 are length units, representing values of linear measurement. Support is also included for pixel and percent unit values. These two unit value types are not, strictly speaking, length values but are included because they are used extensively by Photoshop CS3 for many operations and values. AppleScript Unit Considerations AppleScript provides an additional way of working with unit values. You can provide values with an explicit unit type where unit values are used. When a typed value is provided its type overrides the ruler's current setting. For example, to create a document which is 4 inches wide by 5 inches high you would write: make new document with properties {width:inches 4, ¬ height:inches 5} The values returned for a Photoshop CS3 property that uses units is returned as a value of the current ruler type. Getting the height of the document created above: set docHeight to height of current document returns a value of 5.0, which represents 5 inches based on the current ruler settings. In AppleScript, you can optionally ask for a property value as a particular type. set docHeight to height of current document as points This returns a value of 360 (5 inches x 72 points per inch). The points and picas unit value types are PostScript points, with 72 points per inch. The traditional points and traditional picas unit value types are based on classical type setting values, with 72.27 points per inch. You can convert, or coerce, a unit value from one value type to another. For example, the following script converts a point value to an inch value. set pointValue to 72 as points set inchValue to pointValue as inches

  • 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
56
A type ruler, which is active when using the type tool.
You set measurement unit types for the type ruler using the
type units (TypeUnits/typeUnits)
property.
Note:
These settings correspond to those found in the Photoshop CS3 preference dialog under
Photoshop > Preferences > Units & Rulers
on Mac OS or
Edit > Preferences > Units & Rulers
in
Windows.
Unit Values
All languages support plain numbers for unit values. These values are treated as being of the type
currently specified for the appropriate ruler.
For example, if the ruler units are currently set to inches and the following VBScript statement sets a
document’s size to 3 inches by 3 inches:
docRef.ResizeImage 3,3
If the ruler units had been set to pixels, the document would be 3 pixels by 3 pixels. To ensure that your
scripts produce the expected results you should check and set the ruler units to the type appropriate for
your script. After executing a script the original values of the ruler settings should be restored if changed in
the script. See
‘Setting Ruler and Type Units in a Script’ on page 59
for directions on setting unit values.
Please refer to Photoshop CS3 Help for information about available unit value types.
Special Unit Value Types
The unit values used by Photoshop CS3 are length units, representing values of linear measurement.
Support is also included for pixel and percent unit values. These two unit value types are not, strictly
speaking, length values but are included because they are used extensively by Photoshop CS3 for many
operations and values.
AppleScript Unit Considerations
AppleScript provides an additional way of working with unit values. You can provide values with an
explicit unit type where unit values are used. When a typed value is provided its type overrides the ruler’s
current setting.
For example, to create a document which is 4 inches wide by 5 inches high you would write:
make new document with properties {width:inches 4, ¬
height:inches 5}
The values returned for a Photoshop CS3 property that uses units is returned as a value of the current ruler
type. Getting the height of the document created above:
set docHeight to height of current document
returns a value of 5.0, which represents 5 inches based on the current ruler settings.
In AppleScript, you can optionally ask for a property value as a particular type.
set docHeight to height of current document as points
This returns a value of 360 (5 inches x 72 points per inch).
The
points
and
picas
unit value types are PostScript points, with 72 points per inch. The
traditional
points
and
traditional picas
unit value types are based on classical type setting values, with 72.27
points per inch.
You can convert, or coerce, a unit value from one value type to another. For example, the following script
converts a point value to an inch value.
set pointValue to 72 as points
set inchValue to pointValue as inches