3 Replies Latest reply on Apr 22, 2016 1:51 PM by te_co

    guides on all artboards at the centre

    sylvio33

      I am trying to generate guides at the centre of page. The script below works fine, but if I change the position of the page (and size) the script still keeps generating guides at old coordinates. Here is an illustration:

      What is going wrong?

      The second thing I would like to get is the same two guides on the second artboard at the same position (at the centre with separation of 3 mm).

      Can you help me, please?

       

      The script is like this:

       

      var docRef = app.activeDocument;

      with (docRef) {

      var path1 = docRef.pathItems.add();

      path1.setEntirePath ([[width/2+0.5*8.5,0],[width/2+0.5*8.5,-height]]);

      path1.guides = true;

      var path2 = docRef.pathItems.add();

      path2.setEntirePath ([[width/2-0.5*8.5,0],[width/2-0.5*8.5,-height]]);

      path2.guides = true;

      }

        • 1. Re: guides on all artboards at the centre
          te_co Level 3

          you need to make sure you are in the right coordinate system, artboard or global. if you are in global, your first artboard probably started at 0,0. after you moved it the new coordinate for your path should be width / 2 + 0.5 * 8.5 + the artboards left position. same for the y coordinate.

          • 2. Re: guides on all artboards at the centre
            sylvio33 Level 1

            Can you please suggest how to switch to the global coordinate system?

            • 3. Re: guides on all artboards at the centre
              te_co Level 3

              to convert coordinate systems use

               

              convertCoordinate

                 (coordinate,

                   source,

                   destination)

               

              the parameters 'source' and 'destinations' are the systems and there are called

               

              CoordinateSystem.ARTBOARDCOORDINATESYSTEM

              CoordinateSystem.DOCUMENTCOORDINATESYSTEM

               

              i don't think you need to do any switching between the 2, you need to get the artboard rectangle and add it's position to the position you want for your guides. so if artboard 2 is at 25,50. you need to add 25 and 50 accordingly to your path's coordinates