Adobe 27510753 Scripting Guide - Page 74

Specifying measurement values, UnitValue object

Page 74 highlights

66 Using ExtendScript Tools and Features This figure shows confirmation dialogs with a title value specified. Adobe InDesign CS2 Scripting Guide Specifying measurement values ExtendScript provides the UnitValue object to represent measurement values. The properties and methods of the UnitValue object make it easy to change the value, the unit, or both, or to perform conversions from one unit to another. UnitValue object Represents measurement values that contain both the numeric magnitude and the unit of measurement. UnitValue object constructor The UnitValue constructor creates a new UnitValue object. The keyword new is optional: myVal = new UnitValue (value, unit); myVal = new UnitValue ("value unit"); myVal = new UnitValue (value, "unit"); The value is a number, and the unit is specified with a string in abbreviated, singular, or plural form, as shown in the following table. Abbreviation in ft yd mi mm cm m km pt pc tpt Singular inch foot yard mile millimeter centimeter meter kilometer point pica traditional point Plural inches feet yards miles millimeters centimeters meters kilometers points picas traditional points Comments 2.54 cm 30.48 cm 91.44 cm 1609.344 m inches / 72 points * 12 inches / 72.27

  • 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
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184

66
Using ExtendScript Tools and Features
Adobe InDesign CS2 Scripting Guide
This figure shows confirmation dialogs with a
title
value specified.
Specifying measurement values
ExtendScript provides the
UnitValue
object to represent measurement values. The properties and methods
of the
UnitValue
object make it easy to change the value, the unit, or both, or to perform conversions from
one unit to another.
UnitValue object
Represents measurement values that contain both the numeric magnitude and the unit of measurement.
UnitValue object constructor
The
UnitValue
constructor creates a new
UnitValue
object. The keyword
new
is optional:
myVal = new UnitValue (
value
,
unit
);
myVal = new UnitValue ("
value
unit
");
myVal = new UnitValue (
value
, "
unit
");
The
value
is a number, and the
unit
is specified with a string in abbreviated, singular, or plural form, as shown
in the following table.
Abbreviation
Singular
Plural
Comments
in
inch
inches
2.54 cm
ft
foot
feet
30.48 cm
yd
yard
yards
91.44 cm
mi
mile
miles
1609.344 m
mm
millimeter
millimeters
cm
centimeter
centimeters
m
meter
meters
km
kilometer
kilometers
pt
point
points
inches / 72
pc
pica
picas
points * 12
tpt
traditional point
traditional points
inches / 72.27