Adobe 27510753 Scripting Guide - Page 28

Measurement units, Character, Meaning, Example

Page 28 highlights

20 Getting Started with InDesign Scripting Adobe InDesign CS2 Scripting Guide AppleScript tell application "Adobe InDesign CS2" set mySelection to item 1 of selection move mySelection to {"2p", "6p"} end tell VBScript Set myInDesign = CreateObject("InDesign.Application.CS2") myInDesign.Selection.Item(1).Move Array("2p","6p") JavaScript with(app){ mySelection = selection[0]; mySelection.move(["2p", "6p"]); } Measurement units When you send measurement values to InDesign, you can send either numbers (for example, 14.65) or measurement strings (for example, "1p7.1"). If you send numbers, InDesign uses the publication's current units of measurement; if you send measurement strings, InDesign uses the units of measurement specified in the string. InDesign returns coordinates and other measurement values using the publication's current measurement units. In some cases, these units do not resemble the measurement values shown in the InDesign Transform palette. If the current measurement system is picas, for example, InDesign returns fractional values as decimals, rather than using the picas-and-points notation used by the Transform palette. "1p6," for example, is returned as "1.5." InDesign does this because your scripting system would have trouble trying to perform arithmetic operations using measurement strings-trying to add "0p3.5" to "13p4," for example, would produce a script error; adding .2916 to 13.333 (the converted pica measurements) will not. If your script depends on adding, subtracting, multiplying, or dividing specific measurement values, you might want to set the corresponding measurement units at the beginning of the script. At the end of the script, you can set the measurement units back to whatever they were before you ran the script. Or you can use measurement overrides, as many of the example scripts do. A measurement override is a string containing a special character, as shown in the following examples. Character p pt mm cm c i (or in) Meaning picas (optionally with additional points after the p) points millimeters centimeters ciceros (optionally with additional didots after the c) inches Example 1p6 18pt 6.35mm .635cm 1.4c .25i

  • 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

20
Getting Started with InDesign Scripting
Adobe InDesign CS2 Scripting Guide
AppleScript
tell application "Adobe InDesign CS2"
set mySelection to item 1 of selection
move mySelection to {"2p", "6p"}
end tell
VBScript
Set myInDesign = CreateObject("InDesign.Application.CS2")
myInDesign.Selection.Item(1).Move Array("2p","6p")
JavaScript
with(app){
mySelection = selection[0];
mySelection.move(["2p", "6p"]);
}
Measurement units
When you send measurement values to InDesign, you can send either numbers (for example, 14.65) or
measurement strings (for example, “1p7.1”). If you send numbers, InDesign uses the publication’s current units
of measurement; if you send measurement strings, InDesign uses the units of measurement specified in the
string.
InDesign returns coordinates and other measurement values using the publication’s current measurement
units. In some cases, these units do not resemble the measurement values shown in the InDesign Transform
palette. If the current measurement system is picas, for example, InDesign returns fractional values as
decimals, rather than using the picas-and-points notation used by the Transform palette. “1p6,” for example,
is returned as “1.5.” InDesign does this because your scripting system would have trouble trying to perform
arithmetic operations using measurement strings—trying to add “0p3.5” to “13p4,” for example, would
produce a script error; adding .2916 to 13.333 (the converted pica measurements) will not.
If your script depends on adding, subtracting, multiplying, or dividing specific measurement values, you
might want to set the corresponding measurement units at the beginning of the script. At the end of the
script, you can set the measurement units back to whatever they were before you ran the script. Or you can
use measurement overrides, as many of the example scripts do. A measurement override is a string containing
a special character, as shown in the following examples.
Character
Meaning
Example
p
picas (optionally with additional points after the p)
1p6
pt
points
18pt
mm
millimeters
6.35mm
cm
centimeters
.635cm
c
ciceros (optionally with additional didots after the c)
1.4c
i
(or in)
inches
.25i