5 Replies Latest reply on May 15, 2017 11:56 AM by Somebobby

    Setting Baseline and Document Grid

    Sigurdur Armannsson Level 2

      I have an idea for an InDesign script which I think would be nice to utilize. I have gathered a lot of the recommended stuff to read how to make such scripts but it will take a lot of time for me to get to the point of making this script. I am now at the point of just passing the Hello World stage.

      In the meantime I wonder if someone with more ability would like to and maybe have some fun solving this.


      So far I have found in the documents a sniplet that works as the end of the script but it has to get some additional info to work in the way I want. Here is the script, taken from one of Adobe's JavaScript tutorials:



      var myDocument = app.activeDocument;
      //Set the document measurement units to points.
      myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.points;
      myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.points;
      //Set up grid preferences.
      baselineStart = 0;
      baselineDivision = 11.225;
      baselineShown = true;
      horizontalGridlineDivision = 11.232;
      horizontalGridSubdivision = 1
      verticalGridlineDivision = 11.225;
      verticalGridSubdivision = 1
      documentGridShown = true;


      I put in different numbers from what was in that example and that is exactly what I need the script to do.


      What needs to before this part is excecuted is:


      1. The script gets the document size, W and H

      2. The script opens up a dialog box where the user put in the font leading (L) he wants to use for the baselineDivision. Let's say 11.2pt. Click OK.

           I think baselineStart and vertical and horizontalGridlineSubdivision should be as they are here.

      3. The script now calculates:

           H/L=R. Rounds off the digits of the result (R) to a whole number and calculates: H/R=VGD (verticalGridlineDivision, same as is used for baselineDivision)

           W/L=R. Rounds off the digits of the result (R) to a whole number and calculates: W/R=HGD (horizontalGridlineDivision)


           and puts the results into the script above which then is excecuted and sets both Baseline Grid and Horizontal and Vertical values for the Document grid.

      4. An added bonus would be a display window that would display the number of gridlinedivisions W and H.


      The point of all this is to set up a Baseline Grid that is evenly distributed all over he page, not leaving half line at the bottom and such. At the same time it calculates Document Grid the same way and it is made up of squares that are almost 1:1 Less than .1% away.

      The last display window would help to calculate columns and rows in a grid but this is also a starting point into another script.


      Any help to a newcomer welcomed.