Skip to main content
Participant
August 30, 2023
Resuelto

Copy Guides Across Documents

  • August 30, 2023
  • 4 respuestas
  • 12932 visualizaciones

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?

Mejor respuesta de 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 respuestas

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

 

Legend
August 31, 2023

But what if the zero of the ruler does not match in the documents?

)

Stephen Marsh
Community Expert
Community Expert
August 31, 2023
quote

But what if the zero of the ruler does not match in the documents?

)


By @r-bin

 

Good point!

 

I haven't tested this... But if this was a problem (I'm guessing that it is, otherwise you wouldn't have mentioned it), one can always reset the origin point with additional code:

 

https://community.adobe.com/t5/photoshop-ecosystem-discussions/feature-request-set-ruler-origin-location-in-photoshop/m-p/12039705