Skip to main content
Known Participant
Dec 25, 2024 1:50 AM UTC
Question

Illustrator changes display units

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?

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

7 replies

Sergey Osokin
Inspiring
Dec 25, 2024 10:23 AM UTC

If you have Windows OS (PC), you can add a piece of VisualBasic code to the JS script that will simulate a keystroke to change the units in the document setup to pixels.

Translate
Known Participant
Dec 25, 2024 11:27 AM UTC

Sorry, can VisualBasic code be inserted directly into my JavaScript script code? Because I'm not very familiar with these

Translate
Sergey Osokin
Inspiring
Dec 25, 2024 12:02 PM UTC

On PC it is possible to create a VBS file and run it while the JS script is running. For Mac OS, this solution does not work.

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

That is: "Edit" > "Preferences" > "Units" > "Pixels", the display unit here

Translate
Legend
Dec 25, 2024 2:21 AM UTC

I achieved it by opening that menu and keystroke manipulation by AppleScript; for Windows, AutoHotkey is available.

Translate
Known Participant
Dec 25, 2024 2:25 AM UTC

Sorry, I'm not very familiar with script code. My code is all from ChatGPT. Can this function be accomplished with javascript? Because I need to insert this function into my own script

Translate