Skip to main content
Participating Frequently
February 21, 2010
Question

Script to place guides around a selection?

  • February 21, 2010
  • 1 reply
  • 1540 views

Hi forum!

Don't know if this is far-fetched... But have anybody seen a script/action that can place some guides around a selection or based on an object's dimensions? It would really make my day to some more productive scripts/plugins when it comes to controlling guides.

Any commercial Mac plugins that has such features?

Thanks!

/Henriko

This topic has been closed for replies.

1 reply

Paul Riggott
Inspiring
February 21, 2010

This will place guides around a selection, CS3 or CS4....


if(documents.length){
var startRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
try {
var SB = activeDocument.selection.bounds;
guideLine(SB[1].value,"Hrzn");
guideLine(SB[3].value,"Hrzn");
guideLine(SB[0].value,"Vrtc");
guideLine(SB[2].value,"Vrtc");
app.preferences.rulerUnits = startRulerUnits;
} catch (e) {
   app.preferences.rulerUnits = startRulerUnits;
    }
}

function guideLine(position, type) { 
    var desc = new ActionDescriptor();
        var desc2 = new ActionDescriptor();
        desc2.putUnitDouble( charIDToTypeID('Pstn'), charIDToTypeID( '#Pxl'), position);
        desc2.putEnumerated( charIDToTypeID('Ornt'), charIDToTypeID('Ornt'), charIDToTypeID(type) );
    desc.putObject( charIDToTypeID('Nw  '), charIDToTypeID('Gd  '), desc2 );
    executeAction( charIDToTypeID('Mk  '), desc, DialogModes.NO );
};

superfetzAuthor
Participating Frequently
February 21, 2010

Hi Paul!


Looks promising... but how do I make the script work in PS4?

Do I use AppleScript Editor? I'm not allowed to save it as .jsx.


/H

My bad - I haven't tried the ExtendScript yet

Paul Riggott
Inspiring
February 21, 2010

If you are not allowed to save a jsx file, the only way I can think of is to wrap the code within AppleScript to run the JavaScript.

I am not very good with AppleScript but there are some on here that are experts(Mark) and I'm sure will assist.