public
Last active

Make Guides Grid with number of guides in Photoshop CS5

  • Download Gist
NumberGuidesGrid.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
var doc = app.activeDocument;
var guides = app.activeDocument.guides;
var w = doc.width;
var h = doc.height;
 
function MakeGuidesGrid(numVerticalGuides, gutterVertical, numHorisontalGuides, gutterHorisontal) {
if (numHorisontalGuides !== 0) {
var j = h / numHorisontalGuides;
for (var i = 0; i < numHorisontalGuides; i++) {
guides.add(Direction.HORIZONTAL, j * i);
guides.add(Direction.HORIZONTAL, j * i + gutterHorisontal);
}
}
if (numVerticalGuides !== 0) {
var z = w / numVerticalGuides;
for (var i = 0; i < numVerticalGuides; i++) {
guides.add(Direction.VERTICAL, z * i);
guides.add(Direction.VERTICAL, z * i + gutterVertical);
}
}
}
MakeGuidesGrid(parseInt(prompt("Insert the number of Vertical guides", 40)), parseInt(prompt("Insert the Vertical gutter size", 10)), parseInt(prompt("Insert the number of Horisontal guides", 40)), parseInt(prompt("Insert the Vertical gutter size", 10)));
//MakeGuidesGrid(40,10,40,10)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.