Copy guides from one doc to another?

Does anyone know if it is possible to copy all guides from one document to another? The 2 documents will be the same exact dimensions and same PPI.

I tried this which seems like it should maybe work but it doesn’t.

var app = require('photoshop').app;
var docGuides=app.activeDocument.guides;
 
//after selecting new document
app.activeDocument.guides=docGuides;  

Also tried using with await too

var app = require('photoshop').app;
var docGuides=await app.activeDocument.guides;
 
//after selecting new document
app.activeDocument.guides=docGuides;  

According to the docs document.guides is a read-only property, so you can’t assign something to it. Unless someone here knows a better solution I would iterate through the guides property (the docs says it’s an indexable structure, so I’d think you can loop through it) and re-create them one by one (with coordinate and direction of the original) in the other doc.

Yeah, it looks that way.

I figured out how to read orientation and coordinates for each guide.

Then new guides can be created based on those. It’s a little more work to do but not too bad to just loop through them all. I’ll post the finished code when it’s working.

1 Like