• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How do I adjust 'Document Setup' units to mm using Javascript in Illustrator?

New Here ,
Oct 13, 2020 Oct 13, 2020

Copy link to clipboard

Copied

Hi,

 

I cant seem to find this in the documentation. I would like to change the Document Units to mm after I have created it using Javascript. Does anyone know how to do this?

 

I have figured out how to do this in the app preferences but I would like to do this in the document setup. Changing it in the app preferences isn't displaying it properly in properties panel.

 

Here's the start of my set up function -

 

function setUp() {
var newDocument = app.documents.add(DocumentColorSpace.CMYK, 842, 595, 2, DocumentArtboardLayout.GridByCol, 40, 3);

docRef = app.activeDocument;

 

//HERE I WANT TO ADJUST THE DOCUMENT UNITS TO MM

}

 

Please see attached screenshot to see the units I am trying to change in the UI.

 

Any help would be appreciated.

TOPICS
Scripting

Views

1.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Community Expert , Oct 13, 2020 Oct 13, 2020

Try the following

var docPreset = new DocumentPreset;
docPreset.width = 842;
docPreset.height = 595;
docPreset.units = RulerUnits.Millimeters;
docPreset.artboardLayout = DocumentArtboardLayout.GridByCol;
docPreset.numArtboards = 2
var newDocument = app.documents.addDocument(DocumentColorSpace.CMYK, docPreset);

-Manan

Votes

Translate

Translate
Guide , Oct 13, 2020 Oct 13, 2020
Adobe
Community Expert ,
Oct 13, 2020 Oct 13, 2020

Copy link to clipboard

Copied

Try the following

var docPreset = new DocumentPreset;
docPreset.width = 842;
docPreset.height = 595;
docPreset.units = RulerUnits.Millimeters;
docPreset.artboardLayout = DocumentArtboardLayout.GridByCol;
docPreset.numArtboards = 2
var newDocument = app.documents.addDocument(DocumentColorSpace.CMYK, docPreset);

-Manan

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Oct 13, 2020 Oct 13, 2020

Copy link to clipboard

Copied

Unfortunately they don't just let us change them with script after creation, it has to be done at the moment of creation as Manan describes - but you can't change it afterwards with javascript. You could potentially use either AppleScript or VBS to activate some menus and send some keys to change the units after creation if that is really a burning need.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 13, 2020 Oct 13, 2020

Copy link to clipboard

Copied

LATEST

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines