Created
October 10, 2012 23:11
-
-
Save jameswburke/3869142 to your computer and use it in GitHub Desktop.
Photoshop Script - Generate Grid Guides
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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; | |
// 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; | |
// 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