Script or action for 50% guides
Am I just approaching this wrong, or is this something that will require a script?
Before you record the action, change the ruler from inches (or pixels or whatever) to percent. When the new guide dialog is displayed, the value specified (50% in this case) will be recorded as a percent.
With the ruler set to inches, I tried to overtype "in" with "%," but it still recorded as inches.
BTW: Attached is an action I wrote (and use oven) that places H and V guides at 33%, 66.7%. This comes in handy for cropping.
Last edited by DannyRaphael; 11-06-2003 at 11:40 PM.
Why not record the preference change into the action? I don't know about you but I hate having to go into those preferences. In fact, the script example I have in my Hidden Power of Photoshop CS book specifically goes in and creates an interface for changing ruler units. If you record the change in, you can set the units back (if you use a particular unit type). If you use different unit types, you will be better off with an action that can store the current setting, make the change, insert the guide and restore the original setting.
There's no need to record the Preference change step into the action. When played the action will work regardless of what units are specified in the ruler.
RE: So as long as they're set to percentage when recorded, they'll play back as percentages even if the rulers are set to something else?
Correct. The recorded 'make guide' step specifies a % value, making its application independent of the current ruler setting or physical image size.
oops, Danny, absolutely. Lost my head halfway between a script and an action. You can do it the way I suggest, but it is leaner just to use the recorded state as you say for the placement of the guide. A reason to change the preference would be having several steps that required percentage--turn it on and off. That said, you have to change the preference for the recording, but can throw the step away if you record it, and you don't have to record the switch back.
Funny thing is, one of the actions in HPPSCS actually uses the recorded percentage to place a copyright at 95% right and down in an image...and I removed the preference setting step after recording, so it isn't in the final action.
Last edited by Richard_Lynch; 11-25-2003 at 03:27 AM.
here ya go:
var doc = app.activeDocument;
// set guidelines at 50% on X & Y
var id29 = charIDToTypeID( "Mk " );
var desc9 = new ActionDescriptor();
var id30 = charIDToTypeID( "Nw " );
var desc10 = new ActionDescriptor();
var id31 = charIDToTypeID( "Pstn" );
var id32 = charIDToTypeID( "#Pxl" );
desc10.putUnitDouble( id31, id32, doc.width/2 );
var id33 = charIDToTypeID( "Ornt" );
var id34 = charIDToTypeID( "Ornt" );
var id35 = charIDToTypeID( "Vrtc" );
desc10.putEnumerated( id33, id34, id35 );
var id36 = charIDToTypeID( "Gd " );
desc9.putObject( id30, id36, desc10 );
executeAction( id29, desc9, DialogModes.NO );
var id37 = charIDToTypeID( "Mk " );
var desc11 = new ActionDescriptor();
var id38 = charIDToTypeID( "Nw " );
var desc12 = new ActionDescriptor();
var id39 = charIDToTypeID( "Pstn" );
var id40 = charIDToTypeID( "#Pxl" );
desc12.putUnitDouble( id39, id40, doc.height/2 );
var id41 = charIDToTypeID( "Ornt" );
var id42 = charIDToTypeID( "Ornt" );
var id43 = charIDToTypeID( "Hrzn" );
desc12.putEnumerated( id41, id42, id43 );
var id44 = charIDToTypeID( "Gd " );
desc11.putObject( id38, id44, desc12 );
executeAction( id37, desc11, DialogModes.NO );
// end guidelines=========================================
Last edited by babedieboe; 01-04-2005 at 06:16 AM. Reason: error
* Did you get this code via the Script Listener?
* What advantage would you say a JS has over a 2-step action in this case?
I'm a JS rookie, so I'm always game to learn more about it.
|Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)|
|Thread||Thread Starter||Forum||Replies||Last Post|
|Actions||skydog||Software||9||03-29-2007 02:42 PM|
|CS 2 Action Script||extrememc||Photoshop Help||1||08-03-2006 02:30 AM|
|rules of third script or action?||Lasse||Photoshop Scripting||2||08-17-2005 08:38 PM|
|can a script pick a random action?||okplayer||Photoshop Scripting||4||03-31-2005 03:12 PM|
|A gratitude post for a great action script||RalphBenmurgia||Photo-Based Art||3||02-20-2005 02:43 PM|