Last active
October 7, 2016 01:49
-
-
Save Hoikohroh/833a23e7f35333787caf87f1ed16932d to your computer and use it in GitHub Desktop.
adobe photoshop script "add_guids.jsx"
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
/* | |
add guids v01 | |
adobe photoshop script. | |
add guids active document. | |
*/ | |
//UI Settings | |
var winObj = new Window ("dialog", "add guids", [0,0,260,220]); | |
var panel1 = winObj.add("panel",[20,20,120,120],"Horizontal"); | |
panel1.add("checkbox",[20,15,100,35],"1/2"); | |
panel1.add("checkbox",[20,40,100,60],"1/3"); | |
panel1.add("checkbox",[20,65,100,85],"1/4"); | |
var panel2 = winObj.add("panel",[140,20,240,120],"Vertical"); | |
panel2.add("checkbox",[20,15,100,35],"1/2"); | |
panel2.add("checkbox",[20,40,100,60],"1/3"); | |
panel2.add("checkbox",[20,65,100,85],"1/4"); | |
var chk_clear = winObj.add("checkbox",[40,135,200,155],"Clear all guids"); | |
var btnObj1 = winObj.add("button",[40,170,125,200],"add"); | |
var btnObj2 = winObj.add("button",[135,170,220,200],"close"); | |
//execute | |
btnObj1.onClick = function() { | |
try{ | |
var doc = app.activeDocument; | |
var doc_w = doc.width; | |
var doc_h = doc.height; | |
// clear all guides | |
if(chk_clear.value){ | |
var idclearAllGuides = stringIDToTypeID( "clearAllGuides" ); | |
executeAction( idclearAllGuides, undefined, DialogModes.NO ); | |
}; | |
//add horizontal guids | |
var panel1s = panel1.children; | |
for (var i = 0; i < panel1s.length; i++){ | |
if(panel1s[i].value){ | |
var guid_interval = doc_h / (i + 2) | |
for (var n = 1; n < i+2; n++){ | |
doc.guides.add (Direction.HORIZONTAL,guid_interval * n); | |
}; | |
}; | |
}; | |
//add vertical guids | |
var panel2s = panel2.children; | |
for (var i = 0; i < panel2s.length; i++){ | |
if(panel2s[i].value){ | |
var guid_interval = doc_w / (i + 2) | |
for (var n = 1; n < i+2; n++){ | |
doc.guides.add (Direction.VERTICAL,guid_interval * n); | |
}; | |
}; | |
}; | |
}catch(e){alert (e)}; | |
}; | |
btnObj2.onClick = function() { winObj.close(); }; | |
winObj.center(); | |
winObj.show(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment