Setting Grid Preferences; Snapping To Guides And Grids; Changing Measurement Units And Ruler - Adobe 27510753 - InDesign CS2 - PC Manual

Scripting guide
Hide thumbs Also See for 27510753 - InDesign CS2 - PC:
Table of Contents

Advertisement

Adobe InDesign CS2 Scripting Guide

Setting grid preferences

To control the properties of the document and baseline grid, you set the properties of the gridPreferences
object, as shown in the following script:
//DocumentAndBaselineGrids.jsx
//An InDesign CS2 JavaScript
//Creates a document, then sets preferences for the
//document grid and baseline grid.
var myDocument = app.documents.add();
//Set the document measurement units to points.
myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;
myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;
//Set up grid preferences.
with(myDocument.gridPreferences){
baselineStart = 56;
baselineDivision = 14;
baselineShown = true;
horizontalGridlineDivision = 14;
horizontalGridSubdivision = 5
verticalGridlineDivision = 14;
verticalGridSubdivision = 5
documentGridShown = true;
}

Snapping to guides and grids

All the snap settings for the grids and guides of a document are in the properties of the guidePreferences
and gridPreferences objects. Here's an example:
//GuideAndGridPreferences.jsx
//An InDesign CS2 JavaScript
//Sets preferences for guides and grids.
//Assumes you have a document open.
var myDocument = app.activeDocument;
with(myDocument.guidePreferences){
guidesInBack = true;
guidesLocked = false;
guidesShown = true;
guidesSnapTo = true;
}
with(myDocument.gridPreferences){
documentGridShown = false;
documentGridSnapTo = true;
//Objects "snap" to the baseline grid when
//guidePreferences.guideSnapTo is set to true.
baselineGridShown = true;
}

Changing measurement units and ruler

The example scripts so far used measurement strings (strings that force InDesign to use a specific
measurement unit, "8.5i", for example, for 8.5 inches). They do this because you might be using a different
measurement system when you run the script.
To specify the measurement system used in a script, use the document's viewPreferences object.
//ViewPreferences.jsx
//An InDesign CS2 JavaScript
//Changes the measurement units used by the active document.
//Assumes you have a document open.
var myDocument = app.activeDocument;
with(myDocument.viewPreferences){
Working with Documents in JavaScript
119

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Indesign cs2

Table of Contents