I've used the listener for this and it is a mix of applescript and Javascript.
It creates 2 vertical lines and 2 horizontals. each 20% from the edge of the frame.
So it does work, but I find it happens to slowly for my liking, can the code be condensed to do just that?
Thanks
Matt
Code: Select all
tell application "Adobe Photoshop CC 2014"
tell current document
set {height:aHeight, width:aWidth, resolution:tReso} to it
set aX to (aWidth * 0.2)
set bX to (aWidth * 0.8)
set cY to (aHeight * 0.2)
set dY to (aHeight * 0.8)
--Vertical Lines
do javascript "var idMk = charIDToTypeID( 'Mk ' );
var desc2 = new ActionDescriptor();
var idNw = charIDToTypeID( 'Nw ' );
var desc3 = new ActionDescriptor();
var idPstn = charIDToTypeID( 'Pstn' );
var idPxl = charIDToTypeID( '#Pxl' );
desc3.putUnitDouble( idPstn, idPxl, " & aX & " );
var idOrnt = charIDToTypeID( 'Ornt' );
var idOrnt = charIDToTypeID( 'Ornt' );
var idVrtc = charIDToTypeID( 'Vrtc' );
desc3.putEnumerated( idOrnt, idOrnt, idVrtc );
var idGd = charIDToTypeID( 'Gd ' );
desc2.putObject( idNw, idGd, desc3 );
executeAction( idMk, desc2, DialogModes.NO );"
do javascript "var idMk = charIDToTypeID( 'Mk ' );
var desc2 = new ActionDescriptor();
var idNw = charIDToTypeID( 'Nw ' );
var desc3 = new ActionDescriptor();
var idPstn = charIDToTypeID( 'Pstn' );
var idPxl = charIDToTypeID( '#Pxl' );
desc3.putUnitDouble( idPstn, idPxl, " & bX & " );
var idOrnt = charIDToTypeID( 'Ornt' );
var idOrnt = charIDToTypeID( 'Ornt' );
var idVrtc = charIDToTypeID( 'Vrtc' );
desc3.putEnumerated( idOrnt, idOrnt, idVrtc );
var idGd = charIDToTypeID( 'Gd ' );
desc2.putObject( idNw, idGd, desc3 );
executeAction( idMk, desc2, DialogModes.NO );"
--Horzontal Lines
do javascript "var idMk = charIDToTypeID( 'Mk ' );
var desc6 = new ActionDescriptor();
var idNw = charIDToTypeID( 'Nw ' );
var desc7 = new ActionDescriptor();
var idPstn = charIDToTypeID( 'Pstn' );
var idPxl = charIDToTypeID( '#Pxl' );
desc7.putUnitDouble( idPstn, idPxl, " & cY & " );
var idOrnt = charIDToTypeID( 'Ornt' );
var idOrnt = charIDToTypeID( 'Ornt' );
var idHrzn = charIDToTypeID( 'Hrzn' );
desc7.putEnumerated( idOrnt, idOrnt, idHrzn );
var idGd = charIDToTypeID( 'Gd ' );
desc6.putObject( idNw, idGd, desc7 );
executeAction( idMk, desc6, DialogModes.NO );
"
do javascript "var idMk = charIDToTypeID( 'Mk ' );
var desc6 = new ActionDescriptor();
var idNw = charIDToTypeID( 'Nw ' );
var desc7 = new ActionDescriptor();
var idPstn = charIDToTypeID( 'Pstn' );
var idPxl = charIDToTypeID( '#Pxl' );
desc7.putUnitDouble( idPstn, idPxl, " & dY & " );
var idOrnt = charIDToTypeID( 'Ornt' );
var idOrnt = charIDToTypeID( 'Ornt' );
var idHrzn = charIDToTypeID( 'Hrzn' );
desc7.putEnumerated( idOrnt, idOrnt, idHrzn );
var idGd = charIDToTypeID( 'Gd ' );
desc6.putObject( idNw, idGd, desc7 );
executeAction( idMk, desc6, DialogModes.NO );
"
tell application "Finder"
activate
display dialog "Please adjust guides" with title "Play" buttons {"Play"} default button 1
end tell
--set marquee
do javascript "// make rectangular selection based on 4 guides;
// 2014, use at your own risk;
#target 'photoshop'
if (app.documents.length > 0) {main()};
////// function //////
function main () {
// set to pixels;
var myDocument = app.activeDocument;
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
if (myDocument.guides.length == 4) {
// get guides;
var theVert = new Array;
var theHor = new Array;
for (var m = 0; m < myDocument.guides.length; m++) {
if (myDocument.guides[m].direction == Direction.HORIZONTAL) {theVert.push(myDocument.guides[m].coordinate)}
else {theHor.push(myDocument.guides[m].coordinate)}
};
// make selection;
myDocument.selection.select([[theHor[0], theVert[0]], [theHor[1], theVert[0]], [theHor[1], theVert[1]], [theHor[0], theVert[1]]]);
};
// reset;
app.preferences.rulerUnits = originalRulerUnits;
};"
end tell
end tell
Add 4 guides
-
Mcquiff
Add 4 guides
Excellent and not beyond me to modify for myself.
Many Thanks
Also it just happens!!! rather than the wait I had before.
Many Thanks
Also it just happens!!! rather than the wait I had before.