7 Replies Latest reply: Aug 10, 2012 11:14 AM by JJMack RSS

    Create layers - no dialog

    Ghoulfool Community Member

      The following SL code will create layers

      // =======================================================
      var id65 = charIDToTypeID( "Mk  " );
      var desc10 = new ActionDescriptor();
      var id66 = charIDToTypeID( "null" );
      var ref4 = new ActionReference();
      var id67 = charIDToTypeID( "Lyr " );
      ref4.putClass( id67 );
      desc10.putReference( id66, ref4 );
      var id68 = charIDToTypeID( "Usng" );
      var ref5 = new ActionReference();
      var id69 = charIDToTypeID( "Prpr" );
      var id70 = charIDToTypeID( "Lefx" );
      ref5.putProperty( id69, id70 );
      var id71 = charIDToTypeID( "Lyr " );
      var id72 = charIDToTypeID( "Ordn" );
      var id73 = charIDToTypeID( "Trgt" );
      ref5.putEnumerated( id71, id72, id73 );
      desc10.putReference( id68, ref5 );
      executeAction( id65, desc10, DialogModes.NO );

       

      But is there anyway to supress the "Some aspects of the Effects cannot be reproduced with layers!" dialogue? The irony being that  inclusion of DialogModes.NO doesn't seem to work.

       

      I know I can get around this situation by ticking the "don't show again" box. But that's not what I'm after I just don't want any dialogues popping up whilst the script is running. (fire and forget scripting )

        • 1. Re: Create layers - no dialog
          JJMack MVP

          app.activeDocument.artLayers.add()

           

          On my machine your SL code works without and dialog. If I use the Layer menu I do get dialog for adding layers and dupimg layers. What did you use to have the scriptlistner generate that code.

          • 2. Re: Create layers - no dialog
            Ghoulfool Community Member

            I'm running CS2 and I generated the SL code from right clicking the effects icon (right hand side F in a circle) and choosing create layers. The SL code looks the same if you create the layers from teh menu: Layer-> Layer sryle->create layers. I suspect it may be the type of effect used. I just tried the above code with just the default  red stroke effect and there was no dialogue. Tried again with the default drop shadow and I get the warning dialog. Interesting.

            • 3. Re: Create layers - no dialog
              JJMack MVP

              I was confused I thought you wanted to add a layer for that is what the SL code you posted did on my machine. So I suggested the DOM code "app.activeDocument.artLayers.add()" It seems what your trying to do is a add a layer style to an existing layer. I now see the words Effects can not be done with Layers. Both the menu Layer>Layer Style>Type and the add effect Icon in the layers palette display the Layer Style menu. I would expect the SL code would fo the same.  If you want to add a layer style to a layer using SL code use a style you have loaded in Photoshop. Use the Layer Style Palette. That palette does not display the layer style dialog so you can adjust the style. It just add the canned style with the recorded setting.   Also remember how a Layer style effect looks depends on the dpi resolution of the image and the number of pixels set in the layer style effect. Layer styles can not be recorded in a relative manner setting in the layer style are recorded with absolut pixel size settings not in units like inches which is relative to the documents dpi setting.   So if you add a drop shadow that is 20 pixel in size to a dociment that has 72 dpi print setting the shadow will be 20/72 of and inch on a 300 Dpi document it will be 20/300 of an inch that is 0.28"  and 0.07 they will look very different.

               

              Even the scripting guide with Dom code seems to apply a canned style

               

              Applying styles to layers

              NOTE: This procedure corresponds directly to dragging a style from the Photoshop Styles palette to a layer.

              Your script can apply styles to an ArtLayer object. To apply a style in a script, you use the apply layer

              style/ApplyStyle/applyStyle() command with the style’s name as an argument enclosed in straight

              double quotes.

              NOTE: The layer style names are case sensitive.

              Please refer to Photoshop Help for a list of styles and for more information about styles and the Styles

              palette.

              The following examples set the Puzzle layer style to the layer named “L1.”

               

               

              JS docRef.artLayers["L1"].applyStyle("Puzzle (Image)")

               

              Method

              applyStyle (styleName)

               

              Scriptlistener code function would look something like this"

               

              function addStyle(Style){

                        var idASty = charIDToTypeID( "ASty" );

                            var desc20 = new ActionDescriptor();

                            var idnull = charIDToTypeID( "null" );

                                var ref3 = new ActionReference();

                                var idStyl = charIDToTypeID( "Styl" );

                                ref3.putName( idStyl, Style );

                            desc20.putReference( idnull, ref3 );

                            var idT = charIDToTypeID( "T   " );

                                var ref4 = new ActionReference();

                                var idLyr = charIDToTypeID( "Lyr " );

                                var idOrdn = charIDToTypeID( "Ordn" );

                                var idTrgt = charIDToTypeID( "Trgt" );

                                ref4.putEnumerated( idLyr, idOrdn, idTrgt );

                            desc20.putReference( idT, ref4 );

                        try{

                                  executeAction( idASty, desc20, DialogModes.NO);

                        }catch(e){}

              }

               

               

              Message was edited by: JJMack

              • 4. Re: Create layers - no dialog
                Ghoulfool Community Member

                I can see the confusion, "create layers" is a bit misleading even though that's what the menu item is called. It's not so much the code for creating layers from the effects layer but supressing the dialog that may or may not pop up. The script is designed to flatten out images with layers that have effects and then save them out as PNGS. The script works fine, but the user will have to click on the popup in order to proceed - which is what I want to avoid.

                • 5. Re: Create layers - no dialog
                  JJMack MVP

                  If your adding a layer style instead of using the interactive effect menus add a canned style fro the styles paletts ther will be no pop-up....

                  • 6. Re: Create layers - no dialog
                    Ghoulfool Community Member

                    Unfortunatly, the layer effects have already been created. The script picks up a saved psd and just processes the existing fx layers.

                    • 7. Re: Create layers - no dialog
                      JJMack MVP

                      Ghoulfool wrote:

                       

                      Unfortunatly, the layer effects have already been created. The script picks up a saved psd and just processes the existing fx layers.

                      Then I do not understand what you are doing what do you mean by "just processes the existing fx layers"  That could be all layers except a background layer. How are you processing the layers. Are you trying to copy an FX from one layer to another.  Why dose a layer in a PSD file need to be processed? What is wrong with the layer? I just don't understand what your doing.  First I though you wanted to add a layer without a dialog.  Then I thought you wanted to add a layer style without a dialog.  Now  I look into Layer>Layer Style>Create Layers. I would think you would want the message that tell the user some things can not be done with layers that there will still be layer styles.   I guess I just don't see the pupose of trying to turn a layer style into clipped layers onto a layer instead of a layer style since it is not always posible to do so.