1 Reply Latest reply on Oct 21, 2014 8:34 AM by JJMack

    How to Horizontally attribute any layers

    YaoyongYu Level 1

      How to Horizontally attribute any layers with scripting

      未标题-1.jpg

        • 1. Re: How to Horizontally attribute any layers
          JJMack Most Valuable Participant

          Make a selection and align the layer to it using action manager code. This code should show I  how it can be used, The top part is missing supporting code but its the align function Paul posted that you want.

          // Add Filename Text if called for

          if ( MICollage.msgPnl.StampImage.st.value) {

            stampFilename(textFont,textSizeFactor,textColor,Name);

            loadAlpha("Image " + imageNumber);

           

            var Position = Number(MICollage.msgPnl.grp5a.dd1.selection.index) + 1;

            switch (Position){

            case 1 : align('AdLf'); align('AdTp'); break;

            case 2 : align('AdCH'); align('AdTp'); break;

            case 3 : align('AdRg'); align('AdTp'); break;

            case 4 : align('AdLf'); align('AdCV'); break;

            case 5 : align('AdCH'); align('AdCV'); activeDocument.selection.deselect(); activeDocument.activeLayer.rotate(textAngle); break;

            case 6 : align('AdRg'); align('AdCV'); break;

            case 7 : align('AdLf'); align('AdBt'); break;

            case 8 : align('AdCH'); align('AdBt'); break;

            case 9 : align('AdRg'); align('AdBt'); break;

            default : break;

            }

            // could add code to do something with the image prefix info if it exists in prefixlist

            if ( prefixlist[imageNumber -1] != undefined ) {}

            activeDocument.selection.deselect();

            // Add text Layer's layer style

            addStyle(textStyle);

            }

           

           

          function align(method) {

            var desc = new ActionDescriptor();

            var ref = new ActionReference();

            ref.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );

            desc.putReference( charIDToTypeID( "null" ), ref );

            desc.putEnumerated( charIDToTypeID( "Usng" ), charIDToTypeID( "ADSt" ), charIDToTypeID( method ) );

            try{

            executeAction( charIDToTypeID( "Algn" ), desc, DialogModes.NO );

            }catch(e){}

          }