| Notices | Welcome to RetouchPRO . You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload images and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. | | Photoshop Scripting Learning and sharing for all platforms | 
11-06-2003, 06:56 PM
|  | Janitor | | Join Date: Aug 2001
Posts: 3,921
| | | Script or action for 50% guides I'm trying to make an action that will apply vertical and horizontal guides at the 50% mark in any image, with no success. The action records the absolute position, not the relative position.
Am I just approaching this wrong, or is this something that will require a script? | 
11-06-2003, 08:04 PM
|  | Moderator Patron | | Join Date: Mar 2002 Location: Near Seattle, Washington, USA
Posts: 5,626
| | | 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.
~Danny~
Last edited by DannyRaphael; 11-06-2003 at 11:40 PM.
| 
11-24-2003, 10:32 AM
| | Moderator | | Join Date: Oct 2001 Location: Western NY
Posts: 989
| | 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. | 
11-24-2003, 10:41 AM
|  | Moderator Patron | | Join Date: Mar 2002 Location: Near Seattle, Washington, USA
Posts: 5,626
| | | 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.
~Danny~ | 
11-24-2003, 02:13 PM
|  | Janitor | | Join Date: Aug 2001
Posts: 3,921
| | | 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? | 
11-24-2003, 02:18 PM
|  | Moderator Patron | | Join Date: Mar 2002 Location: Near Seattle, Washington, USA
Posts: 5,626
| | | 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.
~Danny~ | 
11-24-2003, 02:30 PM
|  | Janitor | | Join Date: Aug 2001
Posts: 3,921
| | | Exceedingly cool, thank you. That does the trick. My mistake was thinking that the Make Guides function would be the best way to handle it. | 
11-24-2003, 03:08 PM
| | Moderator | | Join Date: Oct 2001 Location: Western NY
Posts: 989
| | | 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.
| 
01-04-2005, 06:14 AM
| | Junior Member | | Join Date: Dec 2004
Posts: 14
| | | 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
| 
01-04-2005, 11:35 AM
|  | Moderator Patron | | Join Date: Mar 2002 Location: Near Seattle, Washington, USA
Posts: 5,626
| | Quote: |
Originally Posted by babedieboe 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========================================= | Ya gotta love Photoshop: Frequently there are multiple solutions to a given problem and using JavaScript to achieve this goal is a prime example.
Questions:
* 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.
~Danny~ | 
01-04-2005, 01:16 PM
|  | Moderator | | Join Date: May 2004 Location: Goiânia, Brazil
Posts: 1,548
| | Without a doubt this is ScriptListner - if you have a look at the thread I started here you'll find an "interpreted" version.
As to the advantages over the action version the script would only have some advantage if you needed lots and lots of guides (looping) or need to have the flexibility to change the guides at will.
Don't see either applying here though, so I'd stick with the action.
byRo | 
01-04-2005, 10:56 PM
| | Junior Member | | Join Date: Dec 2004
Posts: 14
| | | true. but he asked for it lol.
another advantage would be if you have a major script and need to set guidelines in there as well. In that case you would ALSO need an action to support the (more heavily options of) script......that would be strange...... |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | All times are GMT -6. The time now is 05:05 AM. | |
|