Created — forked from jameswburke/ps-grid-generator.jsx

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

Photoshop Script - Generate Grid Guides

View ps-grid-generator.jsx
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
//Modified version of sprite-grid.jsx by Filip Van Tendeloo
//Fixed for earlier versions of Photoshop based on guideLine function from
//http://www.ps-scripts.com/bb/viewtopic.php?f=9&t=3493&start=0
 
//None of this code is mine
 
// check for document
if(app.documents.length > 0){
// get active document
var psDoc = app.activeDocument;
// get user input on column count
var colWidth = parseInt( prompt("Column size?", 5) );
 
var docWidth = psDoc.width.as('px');
// determine number of columns
var colCount = docWidth / colWidth;
// create vertical guidelines
for(i = 0; i <= colCount; ++i){
guideLine(i * colWidth, 'Vrtc');
}
var docHeight = psDoc.height.as('px');
 
// determine number of rows
var rowCount = docHeight / colWidth;
// create horizontal rows
for(i = 0; i <= rowCount; ++i){
//psDoc.guides.add(Direction.HORIZONTAL, i * colWidth);
guideLine(i * colWidth, 'Hrzn');
}
}
 
 
function guideLine(position, type) {
var id296 = charIDToTypeID( "Mk " );
var desc50 = new ActionDescriptor();
var id297 = charIDToTypeID( "Nw " );
var desc51 = new ActionDescriptor();
var id298 = charIDToTypeID( "Pstn" );
var id299 = charIDToTypeID( "#Pxl" );
desc51.putUnitDouble( id298, id299, position );
var id300 = charIDToTypeID( "Ornt" );
var id301 = charIDToTypeID( "Ornt" );
var id302 = charIDToTypeID( type );
desc51.putEnumerated( id300, id301, id302 );
var id303 = charIDToTypeID( "Gd " );
desc50.putObject( id297, id303, desc51 );
executeAction( id296, desc50, DialogModes.NO );
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.