Skip to main content
Participating Frequently
Sep 24, 2015 2:48 PM UTC
Question

How to change document units?

I have some documents in Points that I want to set to Millimeters using a JSX script, then save them.

I have tried the following code:

var document = app.activeDocument;

document.rulerUnits = RulerUnits.Millimeters;

document.units = RulerUnits.Millimeters;


After executing, the document (File > Document Setup > Units) and the ruler are still in Points.

Is it possible to change the unit by script?


This topic is closed to new replies. Start a new post to keep the conversation going.

3 replies

Known Participant
Dec 25, 2024 1:49 AM UTC

How do I use script or code to modify the display units in the current document in Illustrator? My current units are millimeters (or centimeters) but I want to change it to pixels using a script because I have other scripts running in an environment that require fixed units to be pixels. I need to have the document environment in pixels before running it. I checked a lot of information but couldn't find a solution, is there a way to use code completion?

Translate
Known Participant
Dec 25, 2024 1:44 AM UTC

Hello, I have been with you for many years, have you solved this problem?

Translate
Silly-V
Legend
Sep 24, 2015 5:58 PM UTC

It is a read-only property, app.executeMenuCommand("switchUnits"); only throws a MRAP, changing units is non-recordable in Actions..

What can be done? You can make a new document, set the preferences for your desired units and paste every object into it, or use AppleScript / VB or AHK to try and send keys and clicks into various menus, is about all I can think of.

Translate