3 Replies Latest reply: Dec 7, 2012 2:25 AM by Paul Riggott RSS

    Photoshop Grid to Layer?

    Lynda Spangler Community Member

      Is it possible to turn grids into a layer? I know this can be done with the vanishing point filter but can it be done with normal grids?

       

      I ask because grids are very useful but at times get in the way. If I could create a layer of my grids I could then turn them on and off as needed.

       

      I am using Photoshop CS6 on Windows.

       

      Thanks!

        • 1. Re: Photoshop Grid to Layer?
          Chris Cox Adobe Employee

          The grids in Photoshop are not convertable to pixels/layers.

           

          There are scripts and filters that will render grids.

          • 2. Re: Photoshop Grid to Layer?
            Lynda Spangler Community Member

            Thanks for the information. It would be useful if this was possible.

             

            Do you have a recommendation on a script of filter that will render grids?

            • 3. Re: Photoshop Grid to Layer?
              Paul Riggott Community Member

              This might be of use ...

               

              #target Photoshop
              app.bringToFront();
              function main(){
              if(!documents.length) return;
              var win = new Window( 'dialog', 'Draw Lines' ); 
              g = win.graphics;
              var myBrush = g.newBrush(g.BrushType.SOLID_COLOR, [0.99, 0.99, 0.99, 1]);
              g.backgroundColor = myBrush;
              win.orientation='row';
              win.p1= win.add("panel", undefined, undefined, {borderStyle:"black"}); 
              win.g1 = win.p1.add('group');
              win.g1.orientation = "row";
              win.title = win.g1.add('statictext',undefined,'Draw Lines');
              win.title.alignment="fill";
              var g = win.title.graphics;
              g.font = ScriptUI.newFont("Georgia","BOLDITALIC",22);
              win.g5 =win.p1.add('group');
              win.g5.orientation = "row";
              win.g5.alignment='fill';
              win.g5.spacing=10;
              win.g5.st1 = win.g5.add('statictext',undefined,'Number of lines Vertical');
              win.g5.st1.preferredSize=[150,20];
              win.g5.et1 = win.g5.add('edittext',undefined,'0');
              win.g5.et1.preferredSize=[50,20];
              win.g5.et1.onChanging = function() { 
                if (this.text.match(/[^\-\.\d]/)) { 
                  this.text = this.text.replace(/[^\-\.\d]/g, ''); 
                } 
              };
              win.g10 =win.p1.add('group');
              win.g10.orientation = "row";
              win.g10.alignment='fill';
              win.g10.st1 = win.g10.add('statictext',undefined,'Number of lines Horizontal');
              win.g10.st1.preferredSize=[150,20];
              win.g10.et1 = win.g10.add('edittext',undefined,'0');
              win.g10.et1.preferredSize=[50,20];
              win.g10.et1.onChanging = function() { 
                if (this.text.match(/[^\-\.\d]/)) { 
                  this.text = this.text.replace(/[^\-\.\d]/g, ''); 
                } 
              };
              win.g15 =win.p1.add('group');
              win.g15.orientation = "row";
              win.g15.alignment='fill';
              win.g10.st1 = win.g15.add('statictext',undefined,'Line Width');
              win.g10.dd1 = win.g15.add('dropdownlist');
              for(var t =1;t<21;t++){
                  win.g10.dd1.add('item',t);
                  }
              win.g10.dd1.selection=0;
              win.g100 =win.p1.add('group');
              win.g100.orientation = "row";
              win.g100.alignment='fill';
              win.g100.bu1 = win.g100.add('button',undefined,'Add Lines');
              win.g100.bu1.preferredSize=[110,25];
              win.g100.bu2 = win.g100.add('button',undefined,'Cancel');
              win.g100.bu2.preferredSize=[110,25];
              win.g100.bu1.onClick=function(){
              win.close(0);
              var horz = Number(win.g10.et1.text);
              var vert = Number(win.g5.et1.text);
              var lineWidth = win.g10.dd1.selection.index + 1;
              var crossHatch = activeDocument.artLayers.add(); 
              crossHatch.name = "Draw Lines";
              var spaceH = activeDocument.height.as('px')/(horz+1);
              var spaceV = activeDocument.width.as('px')/(vert+1);
              var spcH = spaceH;
              var spcV = spaceV;
              for(var a =0;a<horz;a++){
                 lineHorzVert(spcH,'H',lineWidth);
                 spcH +=spaceH;
              }
              for(var v =0;v<vert;v++){
                  lineHorzVert(spcV,'V',lineWidth);
                  spcV +=spaceV;
              }
                  
              function lineHorzVert(space,HV,strokeWidth) {
              if(HV.toLowerCase() == 'h'){
                  HV = 'Sngr'; LT = 'Top ';
                  }else{
                       HV = 'Sngc'; LT = 'Left';
                      }
              var Black = new SolidColor();
              Black.rgb.hexValue = '000000';
                  var desc = new ActionDescriptor();
                      var ref = new ActionReference();
                      ref.putProperty( charIDToTypeID('Chnl'), charIDToTypeID('fsel') );
                  desc.putReference( charIDToTypeID('null'), ref );
                      var desc2 = new ActionDescriptor();
                      desc2.putUnitDouble( charIDToTypeID(LT), charIDToTypeID('#Pxl'), space );
                  desc.putObject( charIDToTypeID('T   '), charIDToTypeID(HV), desc2 );
                  try{
                  executeAction( charIDToTypeID('setd'), desc, DialogModes.NO );
                  activeDocument.selection.stroke (Black, strokeWidth, StrokeLocation.CENTER, ColorBlendMode.NORMAL, 100, false);
                  activeDocument.selection.deselect();
                  }catch(e){}
              }
              }
              win.center();
              win.show();
              }
              main();