Announcement

Collapse
No announcement yet.

Script or action for 50% guides

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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?
    Learn by teaching
    Take responsibility for learning

  • #2
    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
    Last edited by DannyRaphael; 11-06-2003, 11:40 PM.

    Comment


    • #3
      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.

      Comment


      • #4
        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~

        Comment


        • #5
          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?
          Learn by teaching
          Take responsibility for learning

          Comment


          • #6
            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~

            Comment


            • #7
              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.
              Learn by teaching
              Take responsibility for learning

              Comment


              • #8
                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, 03:27 AM.

                Comment


                • #9
                  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, 06:16 AM. Reason: error

                  Comment


                  • #10
                    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~

                    Comment


                    • #11
                      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

                      Comment


                      • #12
                        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......

                        Comment

                        Related Topics

                        Collapse

                        Working...
                        X