Adobe 65014293 Scripting Guide - Page 59

Setting ruler and type units in a script, In VBScript

Page 59 highlights

CHAPTER 3: Scripting Photoshop Working with Units 59 AppleScript crop (bounds, height, width) resize canvas (height, width) resize image (height, width) contract (by) expand (by) feather (by) select border (width) translate (delta x, delta y) translate boundary (delta x, delta y) VBScript JavaScript Document.Crop (Bounds, Height, Width) document.crop (bounds, height, width) Document.ResizeCanvas (Height, Width) document.resizeCanvas (height, width) Document.ResizeImage (Height, Width) document.resizeImage (height, width) Selection.Contract (By) selection.contract (by) Selection.Expand (By) selection.expand (by) Selection.Feather (By) selection.feather (by) Selection.SelectBorder (Width) selection.selectBorder (width) Selection.Translate (DeltaX, DeltaY) selection.translate (deltaX, deltaY) Selection.TranslateBoundary selection.translateBoundary (DeltaX, DeltaY) (deltaX, deltaY) Setting ruler and type units in a script 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. AS 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 VBS In VBScript RulerUnits and TypeUnits are properties of the Preferences object, accessed through the Application object's Preferences property as shown below. appRef.Preferences.RulerUnits = 2 'for PsUnits --> 1 (psInches) appRef.Preferences.TypeUnits = 1 'for PsTypeUnits --> 1 (psPixels) appRef.Preferences.PointSize = 2 '2 indicates psPointType --> 2 (PsPostScriptPoints) JS In JavaScript rulerUnits and typeUnits are properties of the Preferences object, accessed through the Application object's preferences property as shown below. app.preferences.rulerUnits = Units.INCHES app.preferences.typeUnits = TypeUnits.PIXELS app.preferences.pointSize = PointType.POSTSCRIPT NOTE: Remember to reset the unit settings back to the original values at the end of a script. See "Working with document preferences" on page 61 for an example of how to do this.

  • 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 Units
59
Setting ruler and type units in a script
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.
AS
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
VBS
In VBScript
RulerUnits
and
TypeUnits
are properties of the
Preferences
object, accessed through the
Application
object's
Preferences
property as shown below.
appRef.Preferences.RulerUnits = 2 'for PsUnits --> 1 (psInches)
appRef.Preferences.TypeUnits = 1 'for PsTypeUnits --> 1 (psPixels)
appRef.Preferences.PointSize = 2
'2 indicates psPointType --> 2 (PsPostScriptPoints)
JS
In JavaScript
rulerUnits
and
typeUnits
are properties of the
Preferences
object, accessed through
the
Application
object's
preferences
property as shown below.
app.preferences.rulerUnits = Units.INCHES
app.preferences.typeUnits = TypeUnits.PIXELS
app.preferences.pointSize = PointType.POSTSCRIPT
N
OTE
:
Remember to reset the unit settings back to the original values at the end of a script. See
“Working
with document preferences” on page 61
for an example of how to do this.
AppleScript
VBScript
JavaScript
crop
(bounds, height, width)
Document.Crop
(Bounds, Height, Width)
document.crop
(bounds, height, width)
resize canvas
(height, width)
Document.ResizeCanvas
(Height, Width)
document.resizeCanvas
(height, width)
resize image
(height, width)
Document.ResizeImage
(Height, Width)
document.resizeImage
(height, width)
contract
(by)
Selection.Contract
(By)
selection.contract
(by)
expand
(by)
Selection.Expand
(By)
selection.expand
(by)
feather
(by)
Selection.Feather
(By)
selection.feather
(by)
select border
(width)
Selection.SelectBorder
(Width)
selection.selectBorder
(width)
translate
(delta x, delta y)
Selection.Translate
(DeltaX, DeltaY)
selection.translate
(deltaX, deltaY)
translate boundary
(delta x, delta y)
Selection.TranslateBoundary
(DeltaX, DeltaY)
selection.translateBoundary
(deltaX, deltaY)