Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Place new guide 1cm from existing guide

Explorer ,
Oct 08, 2018 Oct 08, 2018

My horizontal guide changes position for every PSD file I use, and I want to use a script to place 3 guides 1cm away from the existing guide I have already placed, so I have 4 guides 1cm apart.

What I'm currently doing is setting my ruler origin to the guide and using an action to place 3 more guides. Sometimes I also need 7 guides, or 9 so this changes as well. I know you can place guides from, say, 500px into the PSD using new guide layout, but I need it from the custom horizontal guide I already have set out. If there was even a script to set the ruler origin to this guide, that would be fine too.

Many thanks in advance!

TOPICS
Actions and scripting
781
Translate
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

Community Expert , Oct 08, 2018 Oct 08, 2018

I’m a scripting newb, however it does appear to be possible to find the position of a placed guide, so what you wan’t should be possible, presuming that there is only one guide existing:

How to get exact position of a ruler guide in Photoshop? - Super User

EDIT:

The following is my fledgling start/prototype, presuming only a single guide:

var savedRuler = app.preferences.rulerUnits; //store the current ruler units

app.preferences.rulerUnits = Units.CM; //set the ruler units to CM

var guidePos = app.ac

...
Translate
Adobe
Community Expert ,
Oct 08, 2018 Oct 08, 2018

I’m a scripting newb, however it does appear to be possible to find the position of a placed guide, so what you wan’t should be possible, presuming that there is only one guide existing:

How to get exact position of a ruler guide in Photoshop? - Super User

EDIT:

The following is my fledgling start/prototype, presuming only a single guide:

var savedRuler = app.preferences.rulerUnits; //store the current ruler units

app.preferences.rulerUnits = Units.CM; //set the ruler units to CM

var guidePos = app.activeDocument.guides[0] //retrieve the existing guide

activeDocument.guides.add(Direction.HORIZONTAL, guidePos.coordinate.value + 1); //add new guide +1cm from existing guide

activeDocument.guides.add(Direction.HORIZONTAL, guidePos.coordinate.value - 1); //add new guide -1cm from existing guide

app.preferences.rulerUnits = savedRuler //restore the original ruler units

This simple code will add two new horizontal guides, 1cm above and below the existing guide. I’m sure that lines 04 + 05 can be refined into a single line (the syntax currently eludes me).

If you start with a single guide, and add three more, are these simply added at a positive or negative distance from the original, up or down the height of the image?

What you need is a GUI where you can enter in N number of guides, which is beyond my current knowledge and skillset (I was lucky to make it this far). Unfortunately this code is not much better than your current action… However I hope that this helps you to get the ball rolling, I’m looking forward to what the experts come up with!

Translate
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 Expert ,
Oct 08, 2018 Oct 08, 2018

I would suggest that you verify that guide [0] horizontal.  It seems like what you would want to do is retrieve an array of current guides and set additional horizontal guides above and below current horizontal guides. Or you need to design a  process to determine how many guides you wan to set, or prompt for the number of guides or design a UI for your script.

How to get existing guides.

var theVert = new Array;

var theHor = new Array;

for (var m = 0; m < app.activeDocument.guides.length; m++) {

   if (app.activeDocument.guides.direction == Direction.HORIZONTAL) {theVert.push(app.activeDocument.guides.coordinate)}

   else {theHor.push(app.activeDocument.guides.coordinate)}

};

JJMack
Translate
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
Explorer ,
Oct 09, 2018 Oct 09, 2018
LATEST

Thank you so much!! This is exactly what I was after. At the moment, I'll make multiple copies and each one will have a different line for the amount of rulers needed. Then I'll update my actions with these new scripts. It seems ok at the moment to select from the list of actions how many I need. At least this way is still faster than the way I was doing it before. Thanks again!

Translate
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