Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Transforms guides into lines

Advocate ,
Jul 20, 2017 Jul 20, 2017

Copy link to clipboard

Copied

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

TOPICS
Actions and scripting

Views

13.2K

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guide , Jul 21, 2017 Jul 21, 2017
//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.direction.toString(), Numbe...

Likes

Translate

Translate
Adobe Community Professional ,
Jul 20, 2017 Jul 20, 2017

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jul 20, 2017 Jul 20, 2017

Copy link to clipboard

Copied

I would like to create guides in a document

And then turn them into lines

I would not know how to do it.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 20, 2017 Jul 20, 2017

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 20, 2017 Jul 20, 2017

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jul 20, 2017 Jul 20, 2017

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jul 20, 2017 Jul 20, 2017

Copy link to clipboard

Copied

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.direction.toString(), Number(guides.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 );

};

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jul 21, 2017 Jul 21, 2017

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jul 21, 2017 Jul 21, 2017

Copy link to clipboard

Copied

//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.direction.toString(), Number(guides.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 );

};

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jul 21, 2017 Jul 21, 2017

Copy link to clipboard

Copied

Exceptional just as I wanted it

thank you

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 01, 2018 Aug 01, 2018

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Aug 02, 2018 Aug 02, 2018

Copy link to clipboard

Copied

You do not need to create any selection

all the guides present are colored with the selected color.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 19, 2019 Apr 19, 2019

Copy link to clipboard

Copied

I have the same problem as Suria: it appears that the

activeDocument.selection.stroke (newColour, Number(guideSize), StrokeLocation.OUTSIDE, ColorBlendMode.NORMAL, 100, false);

instructions are trying to load a selection that can't be found. Answering OK or Cancel returns the same effect and interrupt the script.

In PS CC 2018

Any tip?

Thank you!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 18, 2018 Dec 18, 2018

Copy link to clipboard

Copied

Much appreciated!
r-bin many thanks too!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 02, 2020 Apr 02, 2020

Copy link to clipboard

Copied

SuperMerlin, don't know if you're still around, but I'm getting an error on the following line:

singleLine(guides.direction.toString(), Number(guides.coordinate.value).toFixed(0) );

 

The error is "undefined is not an object".  But the console shows that guides=[Guides] and I'm not sure what else to check.

 

Much thanks to any and all advice!  (I'm using Photoshop CC 20.0.2)

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 22, 2020 Apr 22, 2020

Copy link to clipboard

Copied

I also have the same case, Kehr.

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 23, 2020 Jun 23, 2020

Copy link to clipboard

Copied

Hi!

 

You can solve this problem by adding guides[g], when the singleLine method is called (at least it worked for me). 

So the final script look like this:

 

#target photoshop;

if (documents.length) app.activeDocument.suspendHistory('Stroke Guides', 'main()');

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);

};

function main() {
	
	app.preferences.rulerUnits = Units.PIXELS;

    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();

};

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 14, 2021 May 14, 2021

Copy link to clipboard

Copied

LATEST

Works perfectly!! TNX!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 22, 2018 Aug 22, 2018

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Aug 22, 2018 Aug 22, 2018

Copy link to clipboard

Copied

app.preferences.rulerUnits = Units.PIXELS;

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Aug 22, 2018 Aug 22, 2018

Copy link to clipboard

Copied

So that was your first post over here

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Aug 22, 2018 Aug 22, 2018

Copy link to clipboard

Copied

@r-bin,

worked perfectly

Thanks.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines