Do not know if it helps, but, always you need value conversion, you can work with an object called UnitValue.
So, an example:
var test = new UnitValue ("120", "mm"); //here you create you object and set the value and measurement. var testPT = test.as ("pt"); //I'´m using a function, avaliable for this kind of object, to convert the value as point, so you can use in the functions that accept value in points. alert(testPT);
Let me know if it helps
It's "supposed" to be in millimeters, but artboardRect gives me those values :
these values are [left, top, right, bottom] always in points, regardless of the Units used in the user interface, you have to make your unit conversions yourself.
> ... you have to make your unit conversions yourself ...
.. which is (knowing the reported values are in *points*) as simple as
mmvalue = ptvalue*25.4/72;
A formula so short it's *barely* worth the effort of writing a function for.
Oh, thank you both.
My Original Post was quite long, so i realize i shouldn't even have mentionned millimeters and got you confused in my need.
Problem here is, Ai using points, when i try to get a percentage value for the exportOptions i might be applying rounding at the wrong place.
So i'll go with trial and error to see what's inside the Ai export engine.
var AR = artboardRect[left, top, right, bottom]
i was ok with AR-AR being my Artboard width.
Now Ai must use "other" rounded values of my work to determine the size through horizontal scale, because my calculation uses 1200 px to get the 185.xxxxx %, from AR and AR which have not rounded units either.
Ok, forget it all, i've got it.
I found the proper formula, and it was all about rounding :
Now i use :
largeurArtboard = Math.abs( Math.floor(AR)- Math.floor(AR));
coefExport[artboardIndex] = 100 * maxLargeurPx / largeurArtboard;
and i don't forget to set the artBoardClipping value to true.
I get nice 1200px exports, which means, that's how Ai's export work