20 Replies Latest reply on Aug 5, 2016 12:34 PM by rob day

    Grap Paper Script

    ApplePiDesign Level 1

      Hi Experts

      Does anyone know of a script to generate graph paper type grid. It needs 1mm graph with a heavier line for 5mm lines and a different weight line for 10mm lines.

      I have built manually. but it seems like it would be a perfect script ? Tables only allow a minimum space of 1.05mm so no good??

      Any thoughts on how to do this quickly and accurately appreciated.

      (I built manually using step an repeat)

      Thanks

      Phil

        • 1. Re: Grap Paper Script
          philippanmei Level 4

          Give us a screenshot what you are talking about.

          I thought you are wrong, to create a graph script is no needed. You can create with that through table, create table and goto table set up.

           

           

          Thanks

          • 2. Re: Grap Paper Script
            ApplePiDesign Level 1

            Grid Paper.jpgYes table would work IF you could make 1mm divisions, but as far as I can tell 1.05 is the best you can do. Also tedious  as client wants 1mm lines in .25pt thickness 5mm lines in .5pt and 10mm lines in .75pt thickness

            • 3. Re: Grap Paper Script
              Willi Adelberger Most Valuable Participant

              I create always such a grid in Illustrator. I do it with 3 lines (for each width one) in any direction, mulitplied via Illustrator transform effect. Save as PDF/X-4 or AI and place it in InDesign.

              Doing such a grid in InDesign causes higher data volume and provokes unwanted editing inside InDesign.

              • 5. Re: Grap Paper Script
                George_Salnik Adobe Community Professional

                >> Doing such a grid in InDesign causes higher data volume and provokes unwanted editing inside InDesign.

                Place indd to indd and forget about it.

                 

                If you have opportunities to not use illustrator - never use My saying

                • 6. Re: Grap Paper Script
                  Willi Adelberger Most Valuable Participant

                  If a task is better done in Illustrator, use Illustrator. It is here the case.

                  • 7. Re: Grap Paper Script
                    Obi-wan Kenobi Adobe Community Professional

                    Don't be lazy! 1 minute to do it with strokes as I do it in AI! 

                     

                    Capture d’écran 2016-08-05 à 09.58.22.png

                    Capture d’écran 2016-08-05 à 10.00.08.png

                    • 8. Re: Grap Paper Script
                      Peter Kahrel Adobe Community Professional & MVP

                      > Don't be lazy!

                       

                      Why not?!

                       

                      The script below creates a grid on the basis of a selected frame (text frame or rectangle). The grid is placed on a separate layer ('GraphPaper'), so it's easy to hide, lock, or delete the grid. All you need to do is place a frame, select it, and run the script.

                       

                      Peter

                       

                       

                      (function () {
                      
                          if (app.documents.length == 0 || app.selection.length == 0 || /TextFrame|Rectangle/.test(app.selection[0].constructor.name) == false) {
                              alert ('Select a frame');
                              exit();
                          }
                      
                          app.scriptPreferences.measurementUnit = MeasurementUnits.MILLIMETERS;
                          var page = app.activeWindow.activePage;    
                          var gb = app.selection[0].geometricBounds;
                          var zeroPoint = {x: gb[1], y: gb[0]};
                      
                          var height = gb[2]-gb[0];
                          height -= height%10
                          var width = gb[3]-gb[1];
                          width -= width%10
                      
                          function horizontal (step, weight) {
                              var x;
                              var rule;
                              var top = zeroPoint.y;
                              var bottom = zeroPoint.y + height;
                              var stop = width/step;
                              for (var i = 1; i < stop; i++) {
                                  rule = page.graphicLines.add (app.documents[0].layers.item('GraphPaper'), {strokeWeight: weight});
                                  x = zeroPoint.x + (i * step);
                                  rule.paths[0].entirePath = [[x, top], [x, bottom]];
                              }
                          }
                      
                          function vertical (step, weight) {
                              var x;
                              var rule;
                              var left = zeroPoint.x;
                              var right = zeroPoint.x + width;
                              var stop = height/step;
                              for (i = 1; i < stop; i++) {
                                  rule = page.graphicLines.add (app.documents[0].layers.item('GraphPaper'), {strokeWeight: weight});
                                  y = zeroPoint.y + (i * step);
                                  rule.paths[0].entirePath = [[left, y], [right, y]];
                              }
                          }
                      
                          if (!app.documents[0].layers.item('GraphPaper').isValid) {
                              app.documents[0].layers.add ({name: 'GraphPaper'});
                          }
                              
                          horizontal (10, '0.75pt');
                          horizontal (5, '0.5pt');
                          horizontal (1, '0.25pt');
                          vertical (10, '0.75pt');
                          vertical (5, '0.5pt');
                          vertical (1, '0.25pt');
                          page.rectangles.add ({geometricBounds: [zeroPoint.y, zeroPoint.x, zeroPoint.y+height, zeroPoint.x+width], strokeWeight: '0.75pt'});
                          app.selection[0].remove();
                          
                      }());
                      
                      2 people found this helpful
                      • 9. Re: Grap Paper Script
                        Obi-wan Kenobi Adobe Community Professional

                        Aha!

                         

                        Hi Peter,

                         

                        Simply Great!  Really a tool for Lazy!  I'm just saving it in "Peter Kahrel"'s folder in my ID Script Panel folder!

                         

                        Thanks again! 

                        • 10. Re: Grap Paper Script
                          Obi-wan Kenobi Adobe Community Professional

                          Peter,

                           

                          Possible with different colors? 

                          • 11. Re: Grap Paper Script
                            Abambo Level 4

                            There are many ways to Rome...

                            • 12. Re: Grap Paper Script
                              Abambo Level 4

                              The script is there I suppose and it looks nice and neat and I like it, but I'm for Willi's solution in Illustrator. Writing a script needs debugging and that can be complex. Scripts for such simple things should only be written if there is a huge need for the functionality. Here we have some manual solutions I imagine, that are faster then writing and debugging a script.

                              • 13. Re: Grap Paper Script
                                Obi-wan Kenobi Adobe Community Professional

                                Yeah! … Now that we have the graph paper, we can draw the plan to fly to Rome! 

                                • 14. Re: Grap Paper Script
                                  Obi-wan Kenobi Adobe Community Professional

                                  I don't know if something exists in AI to do it faster than Peter's script but do it in ID, copy and paste it in AI doc is truly cool!

                                  … and it works!

                                   

                                  … I'm really tired now! 

                                  • 15. Re: Grap Paper Script
                                    Abambo Level 4

                                    Peter's script is great, but the time it takes to write and debug, you could fill some sheets with different lining patterns. But when you have the script ready, it's unbeatable fast.

                                    • 16. Re: Grap Paper Script
                                      Obi-wan Kenobi Adobe Community Professional

                                      I've read its code! With a little [JS] work, I think it could be not so difficult to create an UI to define all the variables [stroke sizes, colors, cotations].

                                       

                                      … I already love this script! 

                                      • 17. Re: Grap Paper Script
                                        rob day Adobe Community Professional & MVP

                                        I think it could be not so difficult to create an UI to define all the variables [stroke sizes, colors, cotations].

                                         

                                        You could avoid the UI and make and assign an object style, then you could manipulate the grid via the styles.

                                        • 18. Re: Grap Paper Script
                                          rob day Adobe Community Professional & MVP

                                          If all you want to do is change color, just group the grid, then select and change the stroke color

                                           

                                           

                                          Screen Shot 2016-08-05 at 2.49.21 PM.png

                                          • 19. Re: Grap Paper Script
                                            Obi-wan Kenobi Adobe Community Professional

                                            Rob,

                                             

                                            When I talk about UI, I mean: choose the 3 stroke sizes, the 4 colors (one per stroke size + the perimeter), the cotation: e.g. square 1 mm x 1 mm).

                                             

                                             

                                            • 20. Re: Grap Paper Script
                                              rob day Adobe Community Professional & MVP

                                              Right, I understood that. I was suggesting constructing and assigning 3 object styles in the script, then there would be the option of changing colors and strokes anytime after running the script. Grid spacing would need a dialog.