Highlighted

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

New Here ,
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

44

Likes

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

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

New Here ,
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

45

Likes

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
Oct 13, 2020 0
Adobe Community Professional ,
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

Likes

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
Reply
Loading...
Oct 13, 2020 1
Adobe Community Professional ,
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.

Likes

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
Reply
Loading...
Oct 13, 2020 2
Engaged ,
Oct 13, 2020

Copy link to clipboard

Copied

Likes

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
Reply
Loading...
Oct 13, 2020 0