Skip to main content
Known Participant
December 25, 2024
Question

Illustrator changes display units

  • December 25, 2024
  • 2 replies
  • 687 views

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 has been closed for replies.

2 replies

Sergey Osokin
Inspiring
December 25, 2024

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.

Known Participant
December 25, 2024

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

Sergey Osokin
Inspiring
December 25, 2024

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.

Known Participant
December 25, 2024

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

Legend
December 25, 2024

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

Known Participant
December 25, 2024

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