9 Replies Latest reply: Sep 11, 2014 10:17 AM by Kingkong_the_second RSS

    JS - change CS5 Ruler Origin to bottom/left (like CS4)

    CarlosCanto MVP

      Hi guys, after recent user request for help with this much discussed Ruler Origin, and after Jacob having to explain how to do it modifying the user prefs, and after Wade having to explain where to find the file, I wrote a script that does all that for us. It moves the ruler origin to bottom/left or top/left on demand, without having to restart Illustrator. The change is global and permanent (until changed back). After running the script, double-click on the top/left corner of the document, where the rulers meet, to update rulers on active documents.



      #target Illustrator
      //  script.name = switchRulerOriginToCS4nCS5.jsx;
      //  script.description = switches ruler origin to bottom/left (like CS4), and back to top/left (like CS5);
      //  script.required = runs on CS5 only;
      //  script.parent = carlos canto // 8/12/11;
      //  script.elegant = false;
      var appver = Number(String(app.version).split(".")[0]);
      if (appver >= 15)
              //var idoc = app.activeDocument;
              var win = new Window("dialog","Set Coordinate System");
              var grpCoordinates = win.add("group");
              var grpCS4 = grpCoordinates.add("group");
              var lblCS4dummy = grpCS4.add("statictext",undefined,"CS4");
              var panely1 = grpCS4.add("panel");
              var lblCS4 = grpCS4.add("statictext",undefined,"CS4");
              var panelx = grpCoordinates.add("panel");
              var grpCS5 = grpCoordinates.add("group");
              var lblCS5dummy = grpCS5.add("statictext",undefined,"CS5");
              var panely2 = grpCS5.add("panel");
              var lblCS5 = grpCS5.add("statictext",undefined,"CS5");
              grpCoordinates.orientation = "column";
              lblCS4dummy.visible = lblCS5dummy.visible = false;
              var panelradio = win.add("panel", undefined, "Ruler Origin as in...");
              panely1.bounds = {x:0, y:0, width:0, height:60};
              panelx.bounds = {x:0, y:0, width:120, height:0};
              panely2.bounds = {x:0, y:0, width:0, height:60};
              grpCoordinates.spacing = 0;
              win.helpTip = grpCoordinates.helpTip = "Double-Click where the rulers meet to update \rCurrent Doc's Ruler Origin...";
              grpCoordinates.helpTip = "Coded by CarlosCanto";
              grpCS4.helpTip = "CS4: Positive Y moving up";
              grpCS5.helpTip = "CS5: Positive Y moving down";
              lblCS4.helpTip = lblCS5.helpTip = "Don't click me...";
              //add Radio buttons
              var grpRadio = panelradio.add("group");
              var radCS4 = grpRadio.add("radiobutton",undefined,"CS4");
              var radCS5 = grpRadio.add("radiobutton",undefined,"CS5");
              var btnOk = grpRadio.add("button", undefined, "Ok");
              btnOk.size = [40,25];
              btnOk.enabled = false;
              //radCenter.value = true;
              win.defaultElement = lblCS4dummy; // make this element default to prevent hitting "enter" to trigger ok button
              radCS4.onClick = function(){
                  // alert(idoc.name);
                  lblCS4.visible = true;
                  lblCS5.visible = false;
                  btnOk.enabled = true;
              radCS5.onClick = function(){
                  lblCS4.visible = false;
                  lblCS5.visible = true;
                  btnOk.enabled = true;
              btnOk.onClick = function(){
                  app.preferences.setBooleanPreference ("isRulerOriginTopLeft",radCS5.value);
                  app.preferences.setBooleanPreference ("isRulerIn4thQuad",radCS5.value);            
              lblCS4.onClick = lblCS5.onClick = function(){
              alert("...we're so damn curious, aren't we?");
              alert("CS4 and earlier don't need this trick...good bye.")