Aligning a layer relative to another layer with an Action

I was wondering if there is a way to get a layer to align itself underneath another layer.
Example:
Layer 1 is text: NEW YORK
Layer 2 is text: YANKEES
NEW YORK is where I want it at the top of the design.
YANKEES is way at the bottom.
I click on the action and it moves YANKEES to a set position right underneath NEW YORK to look like this:
NEW YORK
YANKEES
... then batch would open the next PSD file and it would repeat the process, moving BULLS underneath CHICAGO making
CHICAGO
BULLS  
the align tool works fine for things like  centering, moving to top, etc during an action. However, what I am  trying to do in batch is align something like YANKEES underneath NEW  YORK and then use a batch process to duplicate this on several designs. 
HOWEVER, what ends up happening, is that the move tool action will move  the layer but it remembers the original distance... in other words in  the next design, CHICAGO will overlap BULLS or DODGERS will be to far  away from LOS ANGELES. Because the size of the CHICAGO, NEW YORK, LOS  ANGELES, etc changes.
Any help is appreciated!!!

You could use "Data Driven Graphics" and set place holders for the two text layers.
Other than that a script is your best bet. The following script will look for two text layers within the document and place the bottom text five pixels below the top text keeping them left aligned.
N.B. Only two text layers are supported.
#target photoshop
main();
function main(){
if(!documents.length) return;
selectAllLayers();
var selectedLayers = getSelectedLayersIdx();
var textLayers =[];
for(var a in selectedLayers){
makeActiveByIndex( Number(selectedLayers[a]), false );
if(activeDocument.activeLayer.kind == LayerKind.TEXT){
     var LB =getLayerBoundsByIndex(selectedLayers[a] );
textLayers.push([[selectedLayers[a]],[LB[0]],[LB[1]],[LB[2]],[LB[3]]]);
if(textLayers.length != 2){
    alert("Only two text layers are supported!");
    return;
textLayers.sort(function(a,b){return a[2]-b[2];});
var startRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
makeActiveByIndex( Number(textLayers[1][0]), false );
var deltaX = Number(textLayers[0][1]) - Number(textLayers[1][1]);
var deltaY = (Number(textLayers[0][4]) + 5) - Number(textLayers[1][2]);
activeDocument.activeLayer.translate(deltaX,deltaY);
app.preferences.rulerUnits = startRulerUnits;
function selectAllLayers(){
activeDocument.activeLayer = activeDocument.layers[activeDocument.layers.length-1];
if(activeDocument.activeLayer.isBackgroundLayer)
activeDocument.activeLayer = activeDocument.layers[activeDocument.layers.length-2];
var BL = activeDocument.activeLayer.name;
activeDocument.activeLayer = activeDocument.layers[0];
    var desc5 = new ActionDescriptor();
        var ref3 = new ActionReference();
        ref3.putName( charIDToTypeID('Lyr '), BL);
    desc5.putReference( charIDToTypeID('null'), ref3 );
    desc5.putEnumerated( stringIDToTypeID('selectionModifier'), stringIDToTypeID('selectionModifierType'), stringIDToTypeID('addToSelectionContinuous') );
    desc5.putBoolean( charIDToTypeID('MkVs'), false );
    executeAction( charIDToTypeID('slct'), desc5, DialogModes.NO );
function getLayerBoundsByIndex( idx ) {
    var ref = new ActionReference();
    ref.putProperty( charIDToTypeID("Prpr") , stringIDToTypeID( "bounds" ));
    ref.putIndex( charIDToTypeID( "Lyr " ), idx );
    var desc = executeActionGet(ref).getObjectValue(stringIDToTypeID( "bounds" ));
    var bounds = [];
    bounds.push(desc.getUnitDoubleValue(stringIDToTypeID('left')));
    bounds.push(desc.getUnitDoubleValue(stringIDToTypeID('top')));
    bounds.push(desc.getUnitDoubleValue(stringIDToTypeID('right')));
    bounds.push(desc.getUnitDoubleValue(stringIDToTypeID('bottom')));
    return bounds;
function getSelectedLayersIdx(){
      var selectedLayers = new Array;
      var ref = new ActionReference();
      ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
      var desc = executeActionGet(ref);
      if( desc.hasKey( stringIDToTypeID( 'targetLayers' ) ) ){
         desc = desc.getList( stringIDToTypeID( 'targetLayers' ));
          var c = desc.count
          var selectedLayers = new Array();
          for(var i=0;i<c;i++){
            try{
               activeDocument.backgroundLayer;
               selectedLayers.push(  desc.getReference( i ).getIndex() );
            }catch(e){
               selectedLayers.push(  desc.getReference( i ).getIndex()+1 );
       }else{
         var ref = new ActionReference();
         ref.putProperty( charIDToTypeID("Prpr") , charIDToTypeID( "ItmI" ));
         ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
         try{
            activeDocument.backgroundLayer;
            selectedLayers.push( executeActionGet(ref).getInteger(charIDToTypeID( "ItmI" ))-1);
         }catch(e){
            selectedLayers.push( executeActionGet(ref).getInteger(charIDToTypeID( "ItmI" )));
      return selectedLayers;
function makeActiveByIndex( idx, visible,add ){
    if(visible == undefined) visible = false;
    if(add == undefined) add=false;
    var desc = new ActionDescriptor();
      var ref = new ActionReference();
      ref.putIndex(charIDToTypeID( "Lyr " ), Number(idx))
      desc.putReference( charIDToTypeID( "null" ), ref );
      if(add) desc.putEnumerated(stringIDToTypeID('selectionModifier'), stringIDToTypeID('selectionModifierType'), stringIDToTypeID('addToSelection'));
      desc.putBoolean( charIDToTypeID( "MkVs" ), visible );
   executeAction( charIDToTypeID( "slct" ), desc, DialogModes.NO );

Similar Messages

  • How to make a selection of a layer delete content and paste another content with Photoshop scripting..?

    how to make a selection of a layer delete content and paste another content with Photoshop scripting..?

    There is a more specific Forum …
    Photoshop Scripting

  • Can one move one layer relative to another in Elements 11?

    Can one move one layer relative to another in Elements 11?

    Yes. Open the layers pallet:
    Window >> Layers
    You can drag layers up and own the stack. Wait until you see a blue line and then drop.

  • How to re align a layer to a composition every frame using a script?

    I have a text layer in a composition. The text on the layer changes every frame. What I want to do is write a script that aligns that layer to the composition every frame.
    If you need further info, just tell me. I need your help in this one.

    I'm not sure what you are trying to do but I think you are looking for a monospaced font. No script I know of will be able to determine the differences between kerning on a metric or optically kerned font to keep the characters all in the same position, but a monospaced font does this automatically. Try changing the font to courier and see if that solves your problem. If it doesn't then explain in detail and provide examples or screenshots that include everything you are having problems with.

  • Can I control the in and out point of a layer with a keyframe?

    Hi all, I'm working in a sort of template for a series of mograph videos. Some sort of motion typography work.
    The animation is always the same but the only thing that changes is the length of the video (for legibility purposes).
    I was wondering if I can control the in and out points of a layer with the keyframes from another layer.
    Lets say Layer's A keyframe from slider 1 position in time is the out point (plus/minus an offset would be also great) of layer B.
    I've been playing with expressions on a regular basis but I don't really know where and how to write an expression like that or if it's possible.
    Thanks in advance

    This should probably be moved to the expression forum then.
    I'm not sure I understood the details of your project but here's a basis: you can do that with an expression in the layer's time remapping property. So if you want a layer to start playing at the second keyframe on another layer, you can try something like (writing in my browser, watch for mistakes):
    //   The "number" of the keyframe (first, second, third, etc)
    var index = 2;
    //   The layer with the keyframes
    var l = {pick-whip the layer with keyframes here};
    //   Just a safety, check the layer has at least enough keyframes
    if (l.numKeys >= index)
         //   If yes, the new time is the difference between the keyframe's time and the current time
        max(0, l.key(index).time-time);
    else
         //   Doesn't matter, let's return 0
        0;

  • Test whether a layer with a specific name exists?

    Is there a simple way to test whether a layer with a specific name exists?

    Simon Dav wrote:
    - Multiple layer names
    - working only for one layer name
    - can you help me for this, how to get multiple names.
    - layers "Background", "Artwork", "diecut", "size", "sign of panel"
    This should work, as one possible approach:
    var doc = app.activeDocument
    var layersToTargetNameArray = ["Background", "Artwork", "diecut", "size", "sign of panel"];
    for (var i = 0, il = doc.layers.length; i < il; i++) {
        var curLayer = doc.layers[i];
        for (var j = 0, jl = layersToTargetNameArray.length; j < jl; j++) {
            if (curLayer.name == layersToTargetNameArray[j]) {
                // do something if layer name found
                curLayer.visible = false; // basic example
            } else {
                // do something else if layer name not found
    Hope it helps your efforts.
    Please Note: If your question exceeds this working response with further unrelated requirements (non related to this thread) you should start a new thread instead for your question, as proper etiquette.

  • How do i take one layer with multiple selections...

    how do i take one layer with multiple selections and make those selections their own layer?

    Yes sir. It w was really hard to explain. It is discontiguous segments that are separated by transparent areas. And I want those non transparent areas to be on their own layer. I have a photo shop file that has a bunch of buttons on them and they are on a transparent background. It is one layer. I want to select all the buttons and put them on their own layers. I can do this manually by selecting a button and cmd Just to a new layer, but when I have 200 buttons it is a daunting task.
    Sent by MailWise<http://www.mail-wise.com/installation/4> – Your emails, with style.

  • Where is the "allow objects on slide to layer with master" in Keynote 6??

    Upgrading to Keynote 6 has broken my presentations. I had borders on the master slides, supposed to appear over any other content.
    Now the content of the slides systematically goes over the master slide. I searched the web and found that in previous versions there was a "allow objects on slide to layer with master" option.
    Where is it now?? Anyone has an idea?
    Thanks

    FYI, this is the error message I'm getting when opening the presentation. "Slide objects were moved in front of master objects"

  • Grouping Adjustment layer with Gradient Fill layer

    Page 151 of "The Missing Manual" suggests that one should be able to group a Levels Adjustment layer with a Gradient Fill layer so that the levels adjustment fades out to one side.
    If I understand this correctly, the setup would be:
    Levels Adjustment Layer (grouped with layer below)
    Gradient Fill layer (with a gradient from Opaque to Transparent)
    Photo in Background layer
    but I cannot get the desired effect of original picture on one side blending through to adjusted levels on the other.
    I can get the desired effect if I dispense with the Gradient Fill layer and simply manually create the gradient on the mask of the Levels Adjustment layer but this loses the advantage of easy adjustment of the gradient.
    [Thanks to those who answered my question about linking a mask to a layer. As this is a separate query, I thought it best to start a new topic]

    Sanders1,
    I thought I'd try it, myself, and got results that I did not expect...
    http://www.pixentral.com/show.php?picture=1OVdT0C7oX46DsPm6TrfT5xxrm3h
    1 - The background image.
    2 - I created a Gradient Fill layer using color (red) to transparent.
    3 - I created a Levels Adjustment layer, set to reduce red and green,
    leaving a blue image.
    4 - I grouped the Levels Adjustment layer with the Gradient Fill layer.
    Is this the type of result you are seeing? I wonder what is the logic.
    Byron

  • Replace colors on multiply layer with predefined color

    Hello,
    This is my first time here and I've tried to find an answer to my question but haven't been able to. Maybe someone can help me whith this.
    My process:
    I scann my artwork (linedrawing)
    I color my artwork with multiply mode on different layers (as i'm sure many do)
    Now what I haven't been able to figure out is how to replace the color on this multiply layer with a predefined color from my colorswatch.
    I've found tutorials on how you can change colour  around by using hue/saturation and stuff like that but I have a predefined colorpalette. So I just want to replace a certain color blue I always work with, for a specific color green from my palette.
    I've used the replace brush tool but the colors that appear are a blend of the first color and the second color I use.
    So my solution so far has been to set up a new layer and color again. I'm hoping there is an easier way.
    Thanks in advance for your suggestions!
    Kind regards,
    Lineke from Amsterdam

    You could have a Color Fill layer for each color selected from your Swatches, with the blending mode set to Multiply, and the layer mask filled with black. Then, paint on the mask with white to do your coloring.

  • Capture Screen from Video Layer with MHP application

    Hi MHP folks!
    Does anybody know how to capture a image / frame from the video layer with a MHP application?
    I am happy about every answer!
    THX a lot
    Bernhard

    There's no standard way to do this in MHP.

  • Creating an O/R layer with TopLink from Ant or a script

    We're currently using JDeveloper and BC4J to generate an O/R layer that simply creates a BC4J entity for each table in our schema with the appropriate associations between tables. The problem with this approach is that it is very brittle. Any change in the database breaks the BC4J layer and we have to recreate the entire thing. Using the JDeveloper wizzard is labor intensive and we want to automate the task of creating a new O/R layer with a script or Ant task, but unfortunately there is no way to do this with JDeveloper.
    Can we use TopLink to generate an O/R layer using a script or Ant task instead of the workbench? It would be a great time saver for us if we could point TopLink to our schema and have it generate an entity per table with the correct associations without having to use the workbench.
    Thanks.

    I have seen some customers do this, although not necessarily with ANT (it was a while ago). We do ship the Deployment Descriptor DTD (search your TopLink install for *.dtd). That should help you generate the mappings. You're on your own with the code, none of the code gen API's are available on the command line outside the MW.

  • Baking a Layer with Camera Movement

    Picking up on my adjacent post...
    I'm trying to bake a layer in a project that has camera movement... we start on a man in closeup and then we zoom out to a long shot. But if I turn off the camera, the man is in closeup and stays that way. Baked and imported into the project, you'll have just the man's head when the camera pulls back in the live project.
    With the camera on during baking, there's the move. But now import that into the project, and the camera motion is double applied -- the baking time and the live time.
    How is this done?
    Thanks very much for your help.

    You can export the layer with the camera turned on, which will "bake in" the camera move, then when you bring it back in, put it in a 2D group so that it's not affected by the project camera.

  • Re-size Layer with Smart Filter without affecting Smart Filter aspect of the layer

    I made a wax seal on photoshop with a lot of embossment, bevelment and a Smart Filter. It's done and I just need to make it smaller so it fits well on my certificate. When I resize it (Ctr + T) It pops up a messgae that reads:
    Adobe Photoshop CS6 Extended
    "Smart Filters applied to layers contained in this group will be turned off temprarily while the transform is being previewed. They will be applied after commiting the transform."
    OK
    [] Don't show again
    I click OK and I re-size the layer with free transform, and then hit enter. The Layer is resized but my Smart Filter which cretaes a wavy affect around the seal is totally distorted.
    How do re-size my layer with smart filter without affecting the smart filter aspect of the layer

    Right-click on the name of the Smart Object layer in the Layers panel to get the menu shown below. Pick "Convert to Smart Object" to encapsulate the SO and its Smart Filter and Layer Styles inside a new SO which can be resized without changes in appearance.

  • Photoshop in Adobe RGB 16 bit don't fill a layer with paint bucket and a color 35.40.35.100.

    I create a new file in RGB profile Adobe RGB 16bit
    take the paint bucket and fill the layer with a color created by selector with the following parameters 35.40.35.100 CMYK and RGB corresponds to 24.20.18 the result is a full level of color 76.73.63.9 but in RGB corresponds to 24.20.18 because the values in cmyk not match ??

    Could you please post screenshots (with the pertinent Panels visible) to illustrate the issue?
    Are you not aware that you cannot reliably define a CMYK color in RGB because the transformation is performed through the Profile Connection Space (Lab) and depends on the involved Color Spaces/ICC profiles (edited) and the Color Settings?

Maybe you are looking for

  • Error while creating J1IJ w.r.t Delivery document

    Dear All, I am getting an error while creating an outgoing excise invoice for a Depot Transaction.I have an OBD with one line item and the PGI has been done for the same .While going into the J1IJ screen w.r.t to the delivery no .Here for the same OB

  • Slow Moving Items in 0IC_MC01 Performance issue

    Hi  i am creating slow moving items report (Report which shows materials for which no transaction has been done for last 3 years) on MP 0IC_MC01 in BI7.0. MP is based on cube 0IC_C03 and Infoobject 0MATERIAL . In query i put rowcount in coloumn with

  • About inventory opening balance & closing balance

    hi all, i want to opening balace and closing balance date wise in my query. how to do it? regards, chetan.

  • OLE EXCEL in foreground

    Hi, i use in abap EXCEL with OLE and visible mode. Every thing works like i want, but when excel starts, it's allways behind the SAP Window. Is there any way to start the excel allways in foreground? Regards, Dieter Moved to GUI - Forum Edited by: Di

  • Before I call Presonus..

    Hello, I am having trouble with a Presonus Firebox. Before I call them I wanted to drop a post here to get some feedback. Equipment: iBook G4 1gb ram WD USB 2.0 external hard drive for audio tracks Presonus Firebox Shure 57 mic M Audio Condenser Mic