Adobe 23101335 Scripting Guide - Page 48

Changing ruler and type units, 3.6 Executing JavaScripts from AS or VB

Page 48 highlights

Scripting Photoshop 3 Executing JavaScripts from AS or VB TABLE 3.3 Command Parameters AppleScript Visual Basic JavaScript translate boundary (delta x, delta y) Selection.TranslateBoundary selection.translateBoundary (DeltaX, DeltaY) (deltaX, deltaY) 3.5.3 Changing ruler and type units The unit type settings of the two Photoshop rulers control how numbers are interpreted when dealing with properties and parameters that support unit values. Be sure to set the ruler units as needed at the beginning of your scripts and save and restore the original ruler settings when your script has completed. In AppleScript ruler units and type units are properties of the settings-object, accessed through the Application object's settings property as shown below. set ruler units of settings to inch units set type units of settings to pixel units set point size of settings to postscript size In Visual Basic and JavaScript ruler units and type units are properties of the Preferences, accessed through the application object's preferences property as shown below. VB: appRef.Preferences.RulerUnits = PsInches appRef.Preferences.TypeUnits = PsTypePixels appRef.Preferences.PointSize = PsPostScriptPoints JS: preferences.rulerUnits = Units.INCHES; preferences.typeUnits = TypeUnits.PIXELS; preferences.pointSize = PointType.POSTSCRIPT; IMPORTANT: Remember to reset the unit settings back to the original values at the end of a script. 3.6 Executing JavaScripts from AS or VB With Photoshop's scripting support you can run JavaScripts from AppleScript or Visual Basic. For Applescript, use do javascript. Photoshop 7.0 Scripting Guide 48

  • 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
  • 88
  • 89
  • 90
  • 91

Photoshop 7.0 Scripting Guide
48
Scripting Photoshop
Executing JavaScripts from AS or VB
3
3.5.3 Changing ruler and type units
The unit type settings of the two Photoshop rulers control how numbers are interpreted when
dealing with properties and parameters that support unit values. Be sure to set the ruler units as
needed at the beginning of your scripts and save and restore the original ruler settings when
your script has completed.
In AppleScript
ruler units
and
type units
are properties of the
settings-object
,
accessed through the Application object's
settings
property as shown below.
set ruler units of settings to inch units
set type units of settings to pixel units
set point size of settings to postscript size
In Visual Basic and JavaScript
ruler units
and
type units
are properties of the
Preferences
, accessed through the application object's preferences property as shown
below.
VB:
appRef.Preferences.RulerUnits = PsInches
appRef.Preferences.TypeUnits = PsTypePixels
appRef.Preferences.PointSize = PsPostScriptPoints
JS:
preferences.rulerUnits = Units.INCHES;
preferences.typeUnits = TypeUnits.PIXELS;
preferences.pointSize = PointType.POSTSCRIPT;
IMPORTANT:
Remember to reset the unit settings back to the original values at the end of a
script.
3.6 Executing JavaScripts from AS or VB
With Photoshop’s scripting support you can run JavaScripts from AppleScript or Visual Basic.
For Applescript, use
do javascript
.
translate boundary
(delta x, delta y)
Selection.TranslateBoundary
(DeltaX, DeltaY)
selection.translateBoundary
(deltaX, deltaY)
T
ABLE
3.3
Command Parameters
AppleScript
Visual Basic
JavaScript