Created
October 26, 2018 18:55
-
-
Save chriscooning/64c8d7e23bbb54b68f6c2e1adeba6bc4 to your computer and use it in GitHub Desktop.
[photoshop] transform guides into lines
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
//Requires Photoshop CS5 or newer | |
app.preferences.rulerUnits = Units.PIXELS; | |
#target photoshop; | |
if(documents.length) app.activeDocument.suspendHistory('Stroke Guides', 'main()'); | |
function main(){ | |
activeDocument.artLayers.add(); | |
activeDocument.activeLayer.name="Stroked Guides"; | |
app.showColorPicker(); | |
var newColour = app.foregroundColor; | |
var guideSize = Window.prompt("Please enter Stroke Size!","1"); | |
var guides = app.activeDocument.guides; | |
var guideArray = []; | |
for( var g = 0; g < guides.length; g++ ){ | |
singleLine(guides[g].direction.toString(), Number(guides[g].coordinate.value).toFixed(0) ); | |
if(Number(guideSize) > 1) | |
activeDocument.selection.stroke (newColour, Number(guideSize), StrokeLocation.OUTSIDE, ColorBlendMode.NORMAL, 100, false); | |
activeDocument.selection.stroke (newColour, Number(guideSize), StrokeLocation.INSIDE, ColorBlendMode.NORMAL, 100, false); | |
} | |
activeDocument.selection.deselect(); | |
}; | |
function singleLine(pos,pixelPos) { | |
var desc5 = new ActionDescriptor(); | |
var ref4 = new ActionReference(); | |
ref4.putProperty( charIDToTypeID('Chnl'), charIDToTypeID('fsel') ); | |
desc5.putReference( charIDToTypeID('null'), ref4 ); | |
var desc6 = new ActionDescriptor(); | |
if(pos == "Direction.VERTICAL"){ | |
desc6.putUnitDouble( charIDToTypeID('Left'), charIDToTypeID('#Pxl'), Number(pixelPos) ); | |
desc5.putObject( charIDToTypeID('T '), charIDToTypeID('Sngc'), desc6 ); | |
}else{ | |
desc6.putUnitDouble( charIDToTypeID('Top '), charIDToTypeID('#Pxl'), Number(pixelPos) ); | |
desc5.putObject( charIDToTypeID('T '), charIDToTypeID('Sngr'), desc6 ); | |
} | |
executeAction( charIDToTypeID('setd'), desc5, DialogModes.NO ); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment