Skip to main content
Participant
August 30, 2023
Answered

Copy Guides Across Documents

  • August 30, 2023
  • 4 replies
  • 12544 views

I absolutley do not understand why the functionality of copying and pasting guides to other documents was removed/moved? One of the most basically needed features of a program has to be messed with. Who's function in the script did it mess with??  I cant find an answer on the web due to multiple changes between versions but documentation has not been updated. Im using 24.7.0. Why not have a simple checkbox option for the current guides in the first document to carry over to any sub-sequent documents after it?

Correct answer SamanthaFury1966

Did you figure out a fix. I don't know how to do anything with html etc. I sure could use a video or some help. Yes why was this removed !! Crying softly!! 


I figured it out thanks to this video here https://www.youtube.com/watch?v=ua9R6ggF5bY  I have the files he used in this video if anyone is desperate for them. 

 

 

4 replies

Stephen Marsh
Community Expert
Community Expert
May 15, 2024

Note, there are issues running the scripts in v2024, as discussed here:

 

Jeff Arola
Community Expert
Community Expert
August 31, 2023
Inspiring
December 20, 2023

I have the script files he used for that video thank Heavens I managed to move them over into 2024. 

Samantha Fury Creating Characters you can love!
Stephen Marsh
Community Expert
Community Expert
August 30, 2023

@Dustin5C22 

 

Have you searched the forum?

 

COPY GUIDES:

/* https://www.reflections-ibs.com/media/1241/guides-copy.jsx */
#target photoshop
main();
function main(){
if(Number(app.version.match(/\d+/)) <12) return;
if(!documents.length) return;
var startRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
    setGuides();
app.preferences.rulerUnits = startRulerUnits;
function setGuides(){
var guides = app.activeDocument.guides;
if(guides.length == 0){
    alert("No guides exist");
    return;
    }
var gH = '';
var gV = '';
for( var g = 0; g < guides.length; g++ ){
    if(guides[g].direction.toString() == 'Direction.HORIZONTAL'){
        gH+=(parseInt(guides[g].coordinate.value));
        gH+=',';
        }else{
            gV+=(parseInt(guides[g].coordinate.value));
            gV+=','
            }
}
gH=gH.replace(/,$/,'');
gV=gV.replace(/,$/,'');
currentGuides = 'Layer Guides' + "�" + gH + "�" + gV;
var desc2 = new ActionDescriptor();
desc2.putString(0, currentGuides.toSource()); 
app.putCustomOptions('7a301ec0-afde-11e1-afa6-0800200c9a66', desc2, true );
}
function displayGuides(){
try{
var desc1 = app.getCustomOptions('7a301ec0-afde-11e1-afa6-0800200c9a66');
var layerGuides = eval(desc1.getString(0));
    }catch(e){return;}
clearGuides();
var ar1 = layerGuides.toString().split('�');
var Hor = ar1[1].toString().split(',');
var Ver = ar1[2].toString().split(',');
for(var H in Hor){
    activeDocument.guides.add(Direction.HORIZONTAL,new UnitValue(Number(Hor[H]),'px'));
    }
for(var V in Ver){
    activeDocument.guides.add(Direction.VERTICAL,new UnitValue(Number(Ver[V]),'px'));
    }
}
}
function clearGuides() { 
   var id556 = charIDToTypeID( "Dlt " ); 
       var desc102 = new ActionDescriptor(); 
       var id557 = charIDToTypeID( "null" ); 
           var ref70 = new ActionReference(); 
           var id558 = charIDToTypeID( "Gd  " ); 
           var id559 = charIDToTypeID( "Ordn" ); 
           var id560 = charIDToTypeID( "Al  " ); 
           ref70.putEnumerated( id558, id559, id560 ); 
       desc102.putReference( id557, ref70 ); 
   executeAction( id556, desc102, DialogModes.NO ); 
};

 

 PASTE GUIDES:

/* https://www.reflections-ibs.com/media/1242/guides-paste.jsx */
#target photoshop
main();
function main(){
if(Number(app.version.match(/\d+/)) <12) return;
if(!documents.length) return;
var startRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
displayGuides();
app.preferences.rulerUnits = startRulerUnits;
function setGuides(){
var guides = app.activeDocument.guides;
if(guides.length == 0){
    alert("No guides exist");
    return;
    }
var gH = '';
var gV = '';
for( var g = 0; g < guides.length; g++ ){
    if(guides[g].direction.toString() == 'Direction.HORIZONTAL'){
        gH+=(parseInt(guides[g].coordinate.value));
        gH+=',';
        }else{
            gV+=(parseInt(guides[g].coordinate.value));
            gV+=','
            }
}
gH=gH.replace(/,$/,'');
gV=gV.replace(/,$/,'');
currentGuides = 'Layer Guides' + "�" + gH + "�" + gV;
var desc2 = new ActionDescriptor();
desc2.putString(0, currentGuides.toSource()); 
app.putCustomOptions('7a301ec0-afde-11e1-afa6-0800200c9a66', desc2, true );
}
function displayGuides(){
try{
var desc1 = app.getCustomOptions('7a301ec0-afde-11e1-afa6-0800200c9a66');
var layerGuides = eval(desc1.getString(0));
    }catch(e){return;}
clearGuides();
var ar1 = layerGuides.toString().split('�');
var Hor = ar1[1].toString().split(',');
var Ver = ar1[2].toString().split(',');
for(var H in Hor){
    activeDocument.guides.add(Direction.HORIZONTAL,new UnitValue(Number(Hor[H]),'px'));
    }
for(var V in Ver){
    activeDocument.guides.add(Direction.VERTICAL,new UnitValue(Number(Ver[V]),'px'));
    }
}
}
function clearGuides() { 
   var id556 = charIDToTypeID( "Dlt " ); 
       var desc102 = new ActionDescriptor(); 
       var id557 = charIDToTypeID( "null" ); 
           var ref70 = new ActionReference(); 
           var id558 = charIDToTypeID( "Gd  " ); 
           var id559 = charIDToTypeID( "Ordn" ); 
           var id560 = charIDToTypeID( "Al  " ); 
           ref70.putEnumerated( id558, id559, id560 ); 
       desc102.putReference( id557, ref70 ); 
   executeAction( id556, desc102, DialogModes.NO ); 
};

 

Here's one for all docs that match the source doc's dimensions:

 

https://community.adobe.com/t5/photoshop-ecosystem-discussions/activedocument-array/m-p/13489983/highlight/true 

 

Another one:

 

c.pfaffenbichler
Community Expert
Community Expert
August 30, 2023
quote

I absolutley do not understand why the functionality of copying and pasting guides to other documents was removed/moved? 

In which version was this a (default) feature? 

What is your actual problem?

 

I can’t find Paul Riggott’s Script on Guide-transfer etc., maybe this can help: 

// take guides from active document and add them  to other open documents after removing their existing guides;
// 2013, use at your own risk; 
#target photoshop
if (app.documents.length > 0 && app.activeDocument.guides.length > 0) {main()};
////// function //////
function main () {
// set to pixels;
var myDocument = app.activeDocument;
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
// collect guides;
var theArray = new Array;
for (var m = 0; m < myDocument.guides.length; m++) {
	theArray.push([myDocument.guides[m].coordinate, myDocument.guides[m].direction])
	};
app.preferences.rulerUnits = originalRulerUnits;
// get all open documents;
var theDocs = app.documents;
for (var o = 0; o < app.documents.length; o++) {
	var thisDocument = app.documents[o];
// proceed if not original document;
	if (thisDocument != myDocument) {
		app.activeDocument = thisDocument;
		var originalRulerUnits = app.preferences.rulerUnits;
		app.preferences.rulerUnits = Units.PIXELS;
// remove existing guides;
		for (var n = thisDocument.guides.length-1; n >=0; n--) {
			thisDocument.guides[n].remove()
			};
// add guides;
		for (var p = 0; p < theArray.length; p++) {
			thisDocument.guides.add(theArray[p][1], theArray[p][0]);
			};
		app.preferences.rulerUnits = originalRulerUnits;
		};
	};
};

 

Participant
August 30, 2023

As far as which version was it removed: While looking for an option to copy guides through a Google search, I see Adobe Support referring to a 2015 version and others for which those choices are not there and nowhere to be found in the latest version. This leads me to believe its been removed. My problem is needing the ability to copy guides from one document to another in order to keep alignment between diffuse, metallic, roughness, and ao maps. I would think that this is a basic need for many artists to have the ability to align between documents. Id rather not have to copy and past my textures in and out of one document just to check alignment leading to unforseen errors. (Unless Im missing a new way of doing this). I did see this script but it seems funny to have to resort to creating ,implementing, and troubleshooting scripts for a basic function that was removed/moved.

c.pfaffenbichler
Community Expert
Community Expert
August 30, 2023

I cannot remember that this was a default option in any Photoshop version. 

Please post the link to the article you mentioned. 

 

quote

I did see this script but it seems funny to have to resort to creating ,implementing, and troubleshooting scripts for a basic function that was removed/moved.

If you don’t want to use Photoshop’s customisation options (Actions, Scripts, Keyboard Shortcuts, …) then you would appear to be stuck with its default behaviour. It’s your own choice. 

 

If you want to post a Feature Request please start a new thread and mark it »Idea« instead of »Discussion«.