Copy link to clipboard
Copied
Hi,
how can I unify the measurement units of preferences. For example: I want to know the amount of space between baseline grid lines. This works:
var grid = app.activeDoucument.gridPreferences.baselineDivision;
However, in InDesign the value is 14.4Pt, but the script tells me: grid = 5.08. I don't know what unit this is supposed to be, but is there a way to get the pt-value?
Thanks for your help.
Copy link to clipboard
Copied
// remember the current preferences
var docPrefs = app.activeDocument.viewPreferences.properties;
// set the document's units to points
doc.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;
// get your grid value
var grid = app.activeDocument.gridPreferences.baselineDivision;
// resore the document's view preferences
app.activeDocument.viewPreferences.properties = docPrefs;
Peter
Copy link to clipboard
Copied
Oh, so this affects all preferences. Thanks.
But why are for example the measurement units used in paragraph styles unaffected. And out of curiosity, how would I change these measurement units?
Copy link to clipboard
Copied
Some items are always measured in points, especially those related to type.
14.4 points == 0.20 inches == 5.08 mm
Copy link to clipboard
Copied
John Hawkinson wrote:
Some items are always measured in points, especially those related to type.
Except that you can always override them, if you really want:
app.selection[0].pointSize = "5mm";
(If you were expecting this to set the size of some selected text to 5 mm, well ... you are correct. But you'll have to think about the meaning of 'point size' in typography: the size of a period? a capital 'X'? a digit? the width of a lowercase 'm'? (Answer: none of the above!))
Copy link to clipboard
Copied
Some items are always measured in points, especially those related to type.
Except that you can always override them, if you really want:
app.selection[0].pointSize = "5mm";
Sure, but it's always measured in points. I you set the default units, or even if you set it that way once, if you ask ID what it is, it will tell you in points:
>> app.selection[0].pointSize="5mm"
5mm
>> app.selection[0].pointSize
14.1732283464567
Copy link to clipboard
Copied
if version CS5 or later
app.scriptPreferences.measurementUnit = MeasurementUnits.POINTS;
//// The measurement unit used during script processing.
// do something
// revert setting
app.scriptPreferences.measurementUnit = AutoEnum.AUTO_VALUE;
can use
here is sample code => http://www.milligramme.cc/wp/archives/3895
mg.