15 Replies Latest reply on Aug 22, 2018 2:26 PM by RicSum

    Transforms guides into lines

    geppettol66959005 Level 2

      good morning

      I'm new to this place

       

       

      I would like to know if there is a way to transform the guides into lines

       

       

      As in the case

       

       

      thank you

       

      Schermata 2017-07-20 alle 11.28.00.png

        • 1. Re: Transforms guides into lines
          c.pfaffenbichler Level 9

          One can assess the guides’ information and create Paths based on that which in turn could be used as the basis of a Shape Layer with Stroke (and merged with some other Layer if necessary) for example.

          • 2. Re: Transforms guides into lines
            geppettol66959005 Level 2

            I would like to create guides in a document

            And then turn them into lines

             

            I would not know how to do it.

            • 3. Re: Transforms guides into lines
              c.pfaffenbichler Level 9

              I told you one approach, others are also available (like creating Selections and filling them).

              • 4. Re: Transforms guides into lines
                c.pfaffenbichler Level 9

                Are you unfamiliar with JavaScript and Photoshop Scripting or is the basic procedure unclear to you?

                • 5. Re: Transforms guides into lines
                  geppettol66959005 Level 2

                  I'm just beginning

                  And I find it very difficult to deal with this language

                   

                   

                  I just wanted to create random guides and then turn them into lines

                  I thought it was simpler

                   

                   

                  But I find it very difficult.

                  • 6. Re: Transforms guides into lines
                    SuperMerlin Level 5

                    try this.

                    //Requires Photoshop CS5 or newer
                    #target photoshop;
                    if(documents.length) app.activeDocument.suspendHistory('Stroke Guides', 'main()'); 
                    function main(){
                    activeDocument.artLayers.add();
                    activeDocument.activeLayer.name="Stroked Guides";
                    var newColour = new SolidColor();
                    newColour.rgb.hexValue="000000";
                    var guides = app.activeDocument.guides;
                    var guideArray = [];
                    for( var g = 0; g < guides.length; g++ ){
                        singleLine(guides[g].direction.toString(), Number(guides[g].coordinate.value).toFixed(0) );
                       activeDocument.selection.stroke (newColour, 1, StrokeLocation.INSIDE, ColorBlendMode.NORMAL, 100, false);
                    }
                    activeDocument.selection.deselect();
                    };
                    function singleLine(pos,pixelPos) {
                    var desc5 = new ActionDescriptor();
                    var ref4 = new ActionReference();
                    ref4.putProperty( charIDToTypeID('Chnl'), charIDToTypeID('fsel') );
                    desc5.putReference( charIDToTypeID('null'), ref4 );
                    var desc6 = new ActionDescriptor();
                    if(pos == "Direction.VERTICAL"){
                    desc6.putUnitDouble( charIDToTypeID('Left'), charIDToTypeID('#Pxl'), Number(pixelPos) );
                    desc5.putObject( charIDToTypeID('T   '), charIDToTypeID('Sngc'), desc6 );
                    }else{
                    desc6.putUnitDouble( charIDToTypeID('Top '), charIDToTypeID('#Pxl'), Number(pixelPos) );
                    desc5.putObject( charIDToTypeID('T   '), charIDToTypeID('Sngr'), desc6 );
                    }
                    executeAction( charIDToTypeID('setd'), desc5, DialogModes.NO );
                    };
                    
                    
                    
                    2 people found this helpful
                    • 7. Re: Transforms guides into lines
                      geppettol66959005 Level 2

                      SuperMerlin exceptional

                      Just what I was looking for

                       

                       

                      I wanted to ask if they could make 2 changes.

                       

                       

                      The first change is the color of the guides I would choose

                      Using the foreground color in the blade tools,

                      Schermata 2017-07-21 alle 11.39.10.png

                       

                      The second change is the size of the line

                      That I would choose from time to time

                      So too small.

                       

                       

                      Thanks again.

                      • 8. Re: Transforms guides into lines
                        SuperMerlin Level 5
                        //Requires Photoshop CS5 or newer
                        #target photoshop;
                        if(documents.length) app.activeDocument.suspendHistory('Stroke Guides', 'main()'); 
                        function main(){
                        activeDocument.artLayers.add();
                        activeDocument.activeLayer.name="Stroked Guides";
                        app.showColorPicker();
                        var newColour = app.foregroundColor;
                        var guideSize = Window.prompt("Please enter Stroke Size!","1");
                        var guides = app.activeDocument.guides;
                        var guideArray = [];
                        for( var g = 0; g < guides.length; g++ ){
                            singleLine(guides[g].direction.toString(), Number(guides[g].coordinate.value).toFixed(0) );
                            if(Number(guideSize) > 1)
                           activeDocument.selection.stroke (newColour, Number(guideSize), StrokeLocation.OUTSIDE, ColorBlendMode.NORMAL, 100, false);
                           activeDocument.selection.stroke (newColour, Number(guideSize), StrokeLocation.INSIDE, ColorBlendMode.NORMAL, 100, false);
                        }
                        activeDocument.selection.deselect();
                        };
                        function singleLine(pos,pixelPos) {
                        var desc5 = new ActionDescriptor();
                        var ref4 = new ActionReference();
                        ref4.putProperty( charIDToTypeID('Chnl'), charIDToTypeID('fsel') );
                        desc5.putReference( charIDToTypeID('null'), ref4 );
                        var desc6 = new ActionDescriptor();
                        if(pos == "Direction.VERTICAL"){
                        desc6.putUnitDouble( charIDToTypeID('Left'), charIDToTypeID('#Pxl'), Number(pixelPos) );
                        desc5.putObject( charIDToTypeID('T   '), charIDToTypeID('Sngc'), desc6 );
                        }else{
                        desc6.putUnitDouble( charIDToTypeID('Top '), charIDToTypeID('#Pxl'), Number(pixelPos) );
                        desc5.putObject( charIDToTypeID('T   '), charIDToTypeID('Sngr'), desc6 );
                        }
                        executeAction( charIDToTypeID('setd'), desc5, DialogModes.NO );
                        };
                        
                        
                        
                        
                        2 people found this helpful
                        • 9. Re: Transforms guides into lines
                          geppettol66959005 Level 2

                          Exceptional just as I wanted it

                           

                          thank you

                          • 10. Re: Transforms guides into lines
                            suria3884474

                            Thanks SuperMerlin, very nice script!

                             

                            Just a question guys:

                             

                            Once running the script;
                            Selecting the color and the stroke.

                             

                            ? Should I create an specific selection, or the Guides itself are enough to make the magic happen?

                             

                            I tried, but the result was:

                            Screen Shot 2018-08-01 at 13.59.30.pngScreen Shot 2018-08-01 at 14.02.59.pngScreen Shot 2018-08-01 at 14.03.08.png

                             

                             

                            Thanksgeppettol66959005 and SuperMerlin

                            • 11. Re: Transforms guides into lines
                              geppettol66959005 Level 2

                              You do not need to create any selection

                              all the guides present are colored with the selected color.

                              • 12. Re: Transforms guides into lines
                                RicSum Level 1

                                it seems this is not compatible with the latest CC 2018.

                                I created a new 800 x 800 document, then dragged 2 guides in (1 horizontally centered and 1 vertically centered). Basically 2 guides marking the center point.

                                I then run the script and all I get is a 1 pixel horizontal sroke across tacross the top (a few pixels down), and a 1 pixel vertical stroke on the left hand side (a few pixes across)?

                                 

                                Can anyone assist?

                                 

                                Thank you all in advance.

                                • 13. Re: Transforms guides into lines
                                  r-bin Level 5
                                  app.preferences.rulerUnits = Units.PIXELS;
                                  
                                  • 14. Re: Transforms guides into lines
                                    Kukurykus Adobe Community Professional

                                    So that was your first post over here

                                    • 15. Re: Transforms guides into lines
                                      RicSum Level 1

                                      @r-bin,

                                      worked perfectly

                                       

                                      Thanks.