8 Replies Latest reply on Feb 10, 2014 6:25 AM by Michael L Hale

    Naming Layer Set ?

    StrongBeaver Level 3

      var layer_c = app.activeDocument.layerSets.add();

      layer_c.layerSets.add().typename("layera");

       

      How do I name a LayerSet ? What am I doing wrong ?

        • 1. Re: Naming Layer Set ?
          Chuck Uebele Adobe Community Professional & MVP

          var layer_c = app.activeDocument.layerSets.add();

          layer_c.name = 'layera';

          • 2. Re: Naming Layer Set ?
            pixxxel schubser MVP & Adobe Community Professional

            Hi StrongBeaver,

            StrongBeaver wrote:

             

            var layer_c = app.activeDocument.layerSets.add();

            layer_c.layerSets.add().typename("layera");

             

            How do I name a LayerSet ? What am I doing wrong ?

             

             

            Do you want to create and rename a new LayerSet? Or you want to create and rename a new LayerSet which is within a new LayerSet?

             

             

            Because of:

             

            var layer_c = app.activeDocument.layerSets.add();

            This create a new LayerSet which is stored in variable layer_c

             

            layer_c.layerSets.add()

            This create a new LayerSet in your LayerSet layer_c. This new Layerset is not stored in a variable.

             

            You can name the second LayerSet like this:

             

            //create a LayerSet
            var layer_c = app.activeDocument.layerSets.add();
            //create a second LayerSet within the first LayerSet
            var layer_c_layerset1 = layer_c.layerSets.add();
            //name the second LayerSet
            layer_c_layerset1.name = 'layera';
            

             

            Have fun

             

            • 3. Re: Naming Layer Set ?
              StrongBeaver Level 3

              Last night I looked in the Photoshop DOM Reference guide, including the Adobe Scripting guide after reading the posts and I'm screaming, well not screaming it was late Where do you find the .name property, I'm probably not making much sense in the laste sentence, I hope you can understand what I mean ?

              • 4. Re: Naming Layer Set ?
                Chuck Uebele Adobe Community Professional & MVP

                The guide is difficult to understand, and a lot of times, I can never get things to work as described in the SDK.  I rely a lot on these forums and ps-scripts.com.

                • 5. Re: Naming Layer Set ?
                  pixxxel schubser MVP & Adobe Community Professional

                  StrongBeaver wrote:

                   

                  … Where do you find the .name property …

                  Scripting is knowledge.

                  If you haven't the knowledge, scripting is mostly searching for samples and very often trial and error. But if something is possible in the UI often is possible in scripting too.

                   

                  Also you can do something like this to get the properties:

                   

                  var layer_c = app.activeDocument.layerSets.add();
                  alert(layer_c.reflect.properties)
                  

                   

                   

                  Have fun

                   

                  • 6. Re: Naming Layer Set ?
                    StrongBeaver Level 3

                    var yellow = app.activeDocument.layerSets.add();

                    yellow.LayerKind.LEVELS();

                    How come an adjustment layer isn't being added to the layerset ?

                     

                    I've noticed Photoshop is a little slow on creating layerSets and renaming them !

                    • 7. Re: Naming Layer Set ?
                      Chuck Uebele Adobe Community Professional & MVP

                      If you want to create a levels adjustment layer, use ScriptListner to create the code.  With the code you have, you are creating a layer set (group), and you can't change that to an adjustment layer. 

                      • 8. Re: Naming Layer Set ?
                        Michael L Hale Level 5

                        app.activeDocument.layerSets.add() adds a new layerSet to the document. So yellow would be a layerSet which doesn't have a kind property. You can only set the kind property of artLayers to TEXT( NORMAL is the default ). To add any other layer type you must use Action Manager.

                         

                        var yellowSet = app.activeDocument.layerSets.add();
                        yellowSet.name ='Yellow layer set';
                        newAdjustmentLevelsLayer(undefined,undefined,undefined,126, 255);
                        app.activeDocument.activeLayer.name = 'My levels layer';
                        
                        function newAdjustmentLevelsLayer( blackIn, whiteIn, gamma, blackOut, whiteOut ) { 
                            var desc = new ActionDescriptor(); 
                                var ref = new ActionReference(); 
                                ref.putClass( stringIDToTypeID( "adjustmentLayer" ) ); 
                            desc.putReference( stringIDToTypeID( "null" ), ref ); 
                                var classDesc = new ActionDescriptor(); 
                                classDesc.putClass( stringIDToTypeID( "type" ), stringIDToTypeID( "levels" ) ); 
                            desc.putObject( stringIDToTypeID( "using" ), stringIDToTypeID( "adjustmentLayer" ), classDesc ); 
                            executeAction( stringIDToTypeID( "make" ), desc, DialogModes.NO ); 
                        
                            var desc = new ActionDescriptor(); 
                                var ref = new ActionReference(); 
                                ref.putEnumerated( stringIDToTypeID( "adjustmentLayer" ), stringIDToTypeID( "ordinal" ), stringIDToTypeID( "targetEnum" ) ); 
                            desc.putReference( stringIDToTypeID( "null" ), ref ); 
                                var adjustmentDesc = new ActionDescriptor(); 
                                    var list = new ActionList(); 
                                        var levelDesc = new ActionDescriptor(); 
                                            var ref = new ActionReference(); 
                                            ref.putEnumerated( stringIDToTypeID( "channel" ), stringIDToTypeID( "channel" ), stringIDToTypeID( "composite" ) ); 
                                        levelDesc.putReference( stringIDToTypeID( "channel" ), ref ); 
                                            var inputList = new ActionList(); 
                                            inputList.putInteger( blackIn!=undefined?blackIn:0 ); 
                                            inputList.putInteger( whiteIn!=undefined?whiteIn:255 ); 
                                        levelDesc.putList( stringIDToTypeID( "input" ), inputList ); 
                                        levelDesc.putDouble(stringIDToTypeID( "gamma" ), gamma!=undefined?gamma:1.0 ); 
                                            var outputList = new ActionList(); 
                                            outputList.putInteger( blackOut!=undefined?blackOut:0 ); 
                                            outputList.putInteger( whiteOut!=undefined?whiteOut:255 ); 
                                        levelDesc.putList( stringIDToTypeID( "output" ), outputList ); 
                                    list.putObject( stringIDToTypeID( "levelsAdjustment" ), levelDesc ); 
                                adjustmentDesc.putList( stringIDToTypeID( "adjustment" ), list ); 
                            desc.putObject( stringIDToTypeID( "to" ), stringIDToTypeID( "levels" ), adjustmentDesc ); 
                            executeAction( stringIDToTypeID( "set" ), desc, DialogModes.NO ); 
                        };