RetouchPRO

Go Back   RetouchPRO > Tools > Software > Photoshop Scripting

Notices

Photoshop Scripting Learning and sharing for all platforms

Reply
 
LinkBack Thread Tools
  #1  
Old 11-06-2003, 06:56 PM
Doug Nelson's Avatar
Janitor
 
Join Date: Aug 2001
Posts: 3,940
Blog Entries: 20
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?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Float This Post!Stumble this Post!Google Bookmark this Post!Yahoo Bookmark this Post!Live Bookmark this Post!Share this post on Facebook
Reply With Quote
  #2  
Old 11-06-2003, 08:04 PM
DannyRaphael's Avatar
Moderator
Patron
 
Join Date: Mar 2002
Location: Near Seattle, Washington, USA
Posts: 5,660
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~
Attached Files
File Type: zip 3x3 v2.zip (546 Bytes, 23 views)

Last edited by DannyRaphael; 11-06-2003 at 11:40 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Float This Post!Stumble this Post!Google Bookmark this Post!Yahoo Bookmark this Post!Live Bookmark this Post!Share this post on Facebook
Reply With Quote
  #3  
Old 11-24-2003, 10:32 AM
Moderator
 
Join Date: Oct 2001
Location: Western NY
Posts: 992
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Float This Post!Stumble this Post!Google Bookmark this Post!Yahoo Bookmark this Post!Live Bookmark this Post!Share this post on Facebook
Reply With Quote
  #4  
Old 11-24-2003, 10:41 AM
DannyRaphael's Avatar
Moderator
Patron
 
Join Date: Mar 2002
Location: Near Seattle, Washington, USA
Posts: 5,660
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~
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Float This Post!Stumble this Post!Google Bookmark this Post!Yahoo Bookmark this Post!Live Bookmark this Post!Share this post on Facebook
Reply With Quote
  #5  
Old 11-24-2003, 02:13 PM
Doug Nelson's Avatar
Janitor
 
Join Date: Aug 2001
Posts: 3,940
Blog Entries: 20
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?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Float This Post!Stumble this Post!Google Bookmark this Post!Yahoo Bookmark this Post!Live Bookmark this Post!Share this post on Facebook
Reply With Quote
  #6  
Old 11-24-2003, 02:18 PM
DannyRaphael's Avatar
Moderator
Patron
 
Join Date: Mar 2002
Location: Near Seattle, Washington, USA
Posts: 5,660
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~
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Float This Post!Stumble this Post!Google Bookmark this Post!Yahoo Bookmark this Post!Live Bookmark this Post!Share this post on Facebook
Reply With Quote
  #7  
Old 11-24-2003, 02:30 PM
Doug Nelson's Avatar
Janitor
 
Join Date: Aug 2001
Posts: 3,940
Blog Entries: 20
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Float This Post!Stumble this Post!Google Bookmark this Post!Yahoo Bookmark this Post!Live Bookmark this Post!Share this post on Facebook
Reply With Quote
  #8  
Old 11-24-2003, 03:08 PM
Moderator
 
Join Date: Oct 2001
Location: Western NY
Posts: 992
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Float This Post!Stumble this Post!Google Bookmark this Post!Yahoo Bookmark this Post!Live Bookmark this Post!Share this post on Facebook
Reply With Quote
  #9  
Old 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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Float This Post!Stumble this Post!Google Bookmark this Post!Yahoo Bookmark this Post!Live Bookmark this Post!Share this post on Facebook
Reply With Quote
  #10  
Old 01-04-2005, 11:35 AM
DannyRaphael's Avatar
Moderator
Patron
 
Join Date: Mar 2002
Location: Near Seattle, Washington, USA
Posts: 5,660
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~
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Float This Post!Stumble this Post!Google Bookmark this Post!Yahoo Bookmark this Post!Live Bookmark this Post!Share this post on Facebook
Reply With Quote
  #11  
Old 01-04-2005, 01:16 PM
byRo's Avatar
Moderator
 
Join Date: May 2004
Location: Goiânia, Brazil
Posts: 1,549
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Float This Post!Stumble this Post!Google Bookmark this Post!Yahoo Bookmark this Post!Live Bookmark this Post!Share this post on Facebook
Reply With Quote
  #12  
Old 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......
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiReddit! Float This Post!Stumble this Post!Google Bookmark this Post!Yahoo Bookmark this Post!Live Bookmark this Post!Share this post on Facebook
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
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


All times are GMT -6. The time now is 03:10 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0
Copyright © 2008 Doug Nelson. All Rights Reserved




1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51