Move RulerOrigin to specific location
Hi,
Apologies if this is obvious, but I just can't work it our after four hours of web searching and trial and error.
I see there was a bug submission - https://illustrator.uservoice.com/forums/601447-illustrator-bugs/suggestions/32003332-bug-when-setting-artboard-ruler-origins - but I'm not sure if that has been fixed in subsequent versions...
I'm transitioning (it's very trendy these days) from Mac to PC so having to rewrite all my AppleScripts, which I was moderately good at, so I thought JS would be easy - but I just can't get my head around the Germanic-compound-words-syntax of it. Old dog, new tricks life crisis. Meh.
Anyway, my problem is I have a script that changes the Ruler Origin, and Illy tells me it has changed it (see below), but in the physical app, nothing has changed:-
#target illustrator
var aDoc = app.activeDocument
//first pass
aDoc.rulerOrigin = [0,0];
aDoc.artboards.rulerOrigin = [0,0];
$.writeln ("Starting origin 0,0")
$.writeln ("Ruler Origin " + (aDoc.rulerOrigin));
$.writeln ("Page Origin " + (aDoc.pageOrigin));
$.writeln ("Ruler Origin (artboards) " + (aDoc.artboards[0].rulerOrigin));
$.writeln ("Artboard size " + (aDoc.artboards[0].artboardRect));
//second pass
aDoc.rulerOrigin = [100,100];
aDoc.artboards.rulerOrigin = [100,100];
$.writeln (" ")
$.writeln ("Starting origin 100,100")
$.writeln ("Ruler Origin " + (aDoc.rulerOrigin));
$.writeln ("Page Origin " + (aDoc.pageOrigin));
$.writeln ("Ruler Origin (artboards) " + (aDoc.artboards[0].rulerOrigin));
$.writeln ("Artboard size " + (aDoc.artboards[0].artboardRect));
/*
RESULTS:
(all dimensions in points, artboard is 200x400)
First pass:
Starting origin 0,0
Ruler Origin 0,0
Page Origin -206,-196
Ruler Origin (artboards) 0,0
Artboard size 0,400,200,0
Second pass:
Starting origin 100,100
Ruler Origin 100,100
Page Origin -306,-296
Ruler Origin (artboards) 0,0
Artboard size -100,300,100,-100
*/
So the "page" ruler origin is changing, but the "artboards" ruler origin is not.
I'm assuming I need to make use of app.coordinateSystem, CoordinateSystem.DOCUMENTCOORDINATESYSTEM and CoordinateSystem.ARTBOARDCOORDINATESYSTEM, but not sure how.
What I'm trying to do is select a path point (anchor) and have the rulerOrigin moved to that anchor (so that anchor x,y becomes 0,0).
Thanks for your help, Em.
