RetouchPRO

Go Back   RetouchPRO > Tools > Software > Photoshop Scripting
Register Blogs FAQ Site Nav Search Today's Posts Mark Forums Read


Photoshop Scripting Learning and sharing for all platforms

Script or action for 50% guides

Reply
 
Thread Tools
  #1  
Old 11-06-2003, 07:56 PM
Doug Nelson's Avatar
Doug Nelson Doug Nelson is offline
Janitor
 
Join Date: Aug 2001
Posts: 7,068
Blog Entries: 21
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?
Reply With Quote top
  #2  
Old 11-06-2003, 09:04 PM
DannyRaphael's Avatar
DannyRaphael DannyRaphael is offline
Moderator
 
Join Date: Mar 2002
Location: Near Seattle, Washington, USA
Posts: 6,300
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, 26 views)

Last edited by DannyRaphael; 11-07-2003 at 12:40 AM.
Reply With Quote top
  #3  
Old 11-24-2003, 11:32 AM
Richard_Lynch's Avatar
Richard_Lynch Richard_Lynch is offline
Senior Member
 
Join Date: Oct 2001
Location: Western NY
Posts: 1,105
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.
Reply With Quote top
  #4  
Old 11-24-2003, 11:41 AM
DannyRaphael's Avatar
DannyRaphael DannyRaphael is offline
Moderator
 
Join Date: Mar 2002
Location: Near Seattle, Washington, USA
Posts: 6,300
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~
Reply With Quote top
  #5  
Old 11-24-2003, 03:13 PM
Doug Nelson's Avatar
Doug Nelson Doug Nelson is offline
Janitor
 
Join Date: Aug 2001
Posts: 7,068
Blog Entries: 21
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?
Reply With Quote top
  #6  
Old 11-24-2003, 03:18 PM
DannyRaphael's Avatar
DannyRaphael DannyRaphael is offline
Moderator
 
Join Date: Mar 2002
Location: Near Seattle, Washington, USA
Posts: 6,300
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~
Reply With Quote top
  #7  
Old 11-24-2003, 03:30 PM
Doug Nelson's Avatar
Doug Nelson Doug Nelson is offline
Janitor
 
Join Date: Aug 2001
Posts: 7,068
Blog Entries: 21
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.
Reply With Quote top
  #8  
Old 11-24-2003, 04:08 PM
Richard_Lynch's Avatar
Richard_Lynch Richard_Lynch is offline
Senior Member
 
Join Date: Oct 2001
Location: Western NY
Posts: 1,105
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 04:27 AM.
Reply With Quote top
  #9  
Old 01-04-2005, 07:14 AM
babedieboe babedieboe is offline
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 07:16 AM. Reason: error
Reply With Quote top
  #10  
Old 01-04-2005, 12:35 PM
DannyRaphael's Avatar
DannyRaphael DannyRaphael is offline
Moderator
 
Join Date: Mar 2002
Location: Near Seattle, Washington, USA
Posts: 6,300
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~
Reply With Quote top
Reply

  RetouchPRO > Tools > Software > Photoshop Scripting


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Actions skydog Software 9 03-29-2007 03:42 PM
CS 2 Action Script extrememc Photoshop Help 1 08-03-2006 03:30 AM
rules of third script or action? Lasse Photoshop Scripting 2 08-17-2005 09:38 PM
can a script pick a random action? okplayer Photoshop Scripting 4 03-31-2005 04:12 PM
A gratitude post for a great action script RalphBenmurgia Photo-Based Art 3 02-20-2005 03:43 PM


All times are GMT -6. The time now is 07:30 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
Copyright © 2016 Doug Nelson. All Rights Reserved