AI does NOT allow measurement units like the othe apps it's points ONLY… SO you can do the math or use UnitValue()
#target illustrator var mm = 2.834645; var doc = app.activeDocument; var myVisibleBounds = doc.visibleBounds; //Rect, which is an array; myVisibleBounds -= 20*mm; //left coordinate (use negative values to add artboard) myVisibleBounds += 20*mm; //ltop coordinate myVisibleBounds += 20*mm; //right coordinate myVisibleBounds -= 20*mm; //bottom coordinate (use negative values to add artboard) doc.artboards.artboardRect = myVisibleBounds;
There is a page of the scriping guide about measurment units when scripting AI… Just 2 methods really…
You were also missing the variable mm and it's value…
So it turns out i'm still struggling with this, i cant get it to the size i need and its driving me mad :s
So the example i'm trying to achieve is
Resize from 860mmx600mm to 700mmx500mm
Thanks for any help!
im not sure if this is the best way but i have changed
var mm = 1;
just worked out my sizes in points then done the maths to make this work
(Oh, and to add to the fun, the artboard coordinate system I think has a positive-down vertical axis but the document coordinate system is positive-up.) Also, the array order of the rect object does seem to be left, top, right, bottom (not sure why Adobe's docs couldn't have mentioned that somewhere).
(Sorry, I spoke too soon about up and down question of the axes. I was confused by a negative value in converted artboard coords I saw for the doc origin of 0,0, which had a negative value in the doc I was looking at.)