🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #9442

Re: [CS2, JS] measurement units

#9442
From: Graham_Woodcock
Date: Sun, 20 Aug 2006 21:32
63 lines
2820 bytes
Try this. It swops both to mmms or points.
//Description: Swap Ruler Units to millimeters or points

/* -----------------------------------------------------------------------------
   Script Description : Swap Ruler Units

Script name : PUB SwapUnits.jsx
   Script revision : 1.0
   Script date : created : 05/02/2006
                        last modified : 05/02/2006

Script development : Copyright: G Woodcock gwoodcock@ananzi.co.za modified from
   						script originally by Cari Jansen www.carijansen.com					



LIABILITY: while every precaution has been taken in the preparation of this script,
		 the script-author shall not have any liability to any person or entity
		 with respect to any liability, loss, or damage caused or alleged to be
		 caused directly or indirectly by the application of this script within
		 Adobe InDesign.

This script maybe freely distributed and modified with attribution.
   ------------------------------------------------------------------------ */

// check if a document is open first...
if (app.documents.length ==0)
{
	alert ("You need to have a document open to run this script");
	exit(0);
}
else
{
	var myDoc = app.activeDocument;
	var myDocVerticalUnits = myDoc.viewPreferences.verticalMeasurementUnits;
	var myDocHorizontalUnits = myDoc.viewPreferences.horizontalMeasurementUnits;
	var myNewUnits = myDoc.viewPreferences;

	switch (myDocVerticalUnits)
	{
		case 2053991795:
			myNewUnits.verticalMeasurementUnits = MeasurementUnits.points;
			break;
		case 2054188905:
			myNewUnits.verticalMeasurementUnits = MeasurementUnits.millimeters;
			break;
		default: //apply for anything else millimeters as ruler units.
			myNewUnits.verticalMeasurementUnits = MeasurementUnits.millimeters;
			break;
	}
	switch (myDocHorizontalUnits)
	{
		case 2053991795:
			myNewUnits.horizontalMeasurementUnits = MeasurementUnits.points;
			break;
		case 2054188905:
			myNewUnits.horizontalMeasurementUnits = MeasurementUnits.millimeters;
			break;
		default: //apply for anything else millimeters as ruler units.
			myNewUnits.horizontalMeasurementUnits = MeasurementUnits.millimeters;
			break;
	}
}
Technical Details
Message-ID: <3bc126a9.0@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news2.volia.net!news.ecp.fr!news.stben.net!webcrossing
References: <C14C12A305C2CCE1F00A527D96155223@in.webcrossing.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,289ed09542fc62ec,start
X-Google-Attributes: gidf939a,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: Graham_Woodcock@adobeforums.com
Newsgroups: adobe.scripting.indesign
Subject: Re: [CS2, JS] measurement units
Message-ID: <3bc126a9.0@webcrossing.la2eafNXanI>
Date: Sun, 20 Aug 2006 14:32:05 -0700
References: <C14C12A305C2CCE1F00A527D96155223@in.webcrossing.la2eafNXanI>
Lines: 75
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news2.volia.net!news.ecp.fr!news.stben.net!webcrossing