Skip navigation
Currently Being Moderated

Create layers - no dialog

Aug 8, 2012 4:15 AM

Tags: #supress_dialog #dialogmodes

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 )

 
Replies
  • JJMack
    5,977 posts
    Jan 9, 2006
    Currently Being Moderated
    Aug 8, 2012 10:29 AM   in reply to Ghoulfool

    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.

     
    |
    Mark as:
  • JJMack
    5,977 posts
    Jan 9, 2006
    Currently Being Moderated
    Aug 9, 2012 10:47 AM   in reply to Ghoulfool

    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

     
    |
    Mark as:
  • JJMack
    5,977 posts
    Jan 9, 2006
    Currently Being Moderated
    Aug 10, 2012 4:22 AM   in reply to Ghoulfool

    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....

     
    |
    Mark as:
  • JJMack
    5,977 posts
    Jan 9, 2006
    Currently Being Moderated
    Aug 10, 2012 11:14 AM   in reply to Ghoulfool

    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.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points