How to get through all the layers?

I would like to write a script to rename all the layers, but I don't know how to do, who can help me?

function traverse( layerSet, callback )
{
  for ( var i = 0; i < layerSet.layers.length; i++ ) {
       var l = layerSet.layers[ i ];
       app.activeDocument.activeLayer = l;
       if ( l.typename == "LayerSet" )
       {
            traverse( l, callback );
       }
       callback( l );
  }
}

function toUpp( l )
{
    l.name = l.name.toUpperCase();
}

traverse( app.activeDocument, toUpp );

In this case, the callback is defining the name of the layer in upper case. The app.activeDocument is a layerSet too. For some reason you need to select a layer before running this script.

Tags: Photoshop

Similar Questions

  • How to get xml all the attributes count?

    Hi Indesigners,

    I tried a lot of time to get all of the xml attributes count in indesign xml and according to the style applied to the xmlAttribute value, I have to do some tasks... Can someone help me...

    Thank you and best regards,

    Vel.

    Finally, I wrote the script to get the xml attributes...

    var doc = app.activeDocument;

    var parastyle = doc.allParagraphStyles;

    var charstyle = doc.allCharacterStyles;

    var currentpara;

    var att, att2, val = 'ParagraphStyles\r', val2 = "CharacterStyles\r";

    [var attNodes = doc.xmlElements[0].evaluateXPathExpression("//*['@']"); "

    var i, t;

    ~ alert (attNodes.length);

    for (i = 0;  I have< attnodes.length;="">

    {

    Try

    {

    att = attNodes [i].xmlAttributes.itemByName ("aid: pstyle") .value;

    Val = val + att + "\r";

    checkpara (ATT);

    }

    catch (e)

    {

    }

    Try

    {

    att2 = attNodes [i].xmlAttributes.itemByName ("aid: cstyle") .value;

    val2 = val2 + att2 + "\r";

    checkchar (att2);

    }

    catch (e)

    {

    }

    }

    Alert (Val);

    Alert (val2);

    function checkpara (currentpara)

    {

    If (IsInArray (ParaStyle, currentpara))

    {

    Alert (currentpara + "Available");

    }

    on the other

    {

    Alert (currentpara + "Missing!");

    }

    }

    function checkchar (currentchar)

    {

    If (IsInArray2 (CharStyle, currentchar))

    {

    Alert (currentchar + "Available");

    }

    on the other

    {

    Alert (currentchar + "Missing!");

    }

    }

    function IsInArray(array,item)

    {

    var retval = false;

    for (var i = 0; i)<>

    {

    If (array [i] .name is point)

    {

    retval = true;

    }

    }

    Return retval;

    }

    function IsInArray2 (array2, item2)

    {

    var retval2 = false;

    for (var i = 0; i)<>

    {

    If (array2 [i] .name is item2)

    {

    retval2 = true;

    }

    }

    Return retval2;

    }

    The above codes will be found the missing character style or paragraph style in the document, which is defined as the value of the xml attribute.

    Thank you and best regards,

    Vel.

  • How you can hightlight all the layers in PS CS?

    That's all I need to know

    for the time being. Thank you.

    Just to clarify the reading of your previous posts, using your

    Photoshop cs and cs2 - cs5 not?

    In photoshop cs (although you can in image ready) you cannot select more than

    layers, you link them to perform operations such as processing of multiple layers

    etc.

    For example, if you want to merge specific layers, in photoshop cs you would connect the

    layer to merge (instead of highlighting or by selecting layers), then choose fusion related.

    In the help (help > Photoshop help) manual supplied with cs, look under layers > linking.

    MTSTUNER

    Post edited by: MTSTUNER

  • home network security - can't get through all the requirments

    original title: home network security

    Have set up a home network on linksys router, I have passwords, but can not access to network from a laptop computer, domain name, password and logon of the user are needed I have router username, router password, network name, network, WEP 128 network security key. I tried several combinations without success. Can someone tell me what names past game etc. the requirement!

    You need to connect to your wireless network SSID of the router and its encryption key (in your case, the encryption WEP 128 bit key). No other information should be necessary.

    If you talk to access another PC on the network, you must first establish the wireless connection. If you have done this, you must provide a login user name and password for the computer that you are trying to access.

    If you still have problems please post back with accurate information and complete what you are doing and this error message appears when you do. Do not assume that anone helping through these forums will know what you are doing and what went wrong based on a generalized description.

    Tricky

  • How to iterate through all the controls in a MXML component

    How can browse you a MXML component controls?

    What kind of objects you need for the loop foreach?

    for each {(var child: UIComponent in parent.children)

  • my sound keep disappearing. When I go to the volume control, it says no device installed. I have been through all the steps. How can I get my sound back?

    my sound keeps disappearing.  I go through all the help and support the steps but still no sound.  the volume control is all grey and says no audio device found.  but the Device Manager indicates that all is well.  What is the problem that I continue to have?

    Hello

    1. the troubleshooting steps are you referring?
    2. don't you make changes on the computer before this problem?

    The following article might be useful.
    No sound in Windows
    http://Windows.Microsoft.com/en-us/Windows/help/no-sound-in-Windows

  • How can I return to my start page without scrolling through all the links I have open?

    In previous versions of Ff, I could go to a menu drop down and go back to my original home page (or another that I had opened) without having to scroll through all the links open back. I can't find a way to do it in 4.0.

    You can get the menu drop-down by clicking on the previous/next buttons or now the left key pressed until the list is displayed.

    If you want the drop-down arrow, you can add it with the add-on of dropmarker rear - https://addons.mozilla.org/firefox/addon/backforward-dropmarker

  • Get all the layers and apply to other documents

    Hello everyone,

    I'm copying all layers from one document to the other. But just copy paste is not enough for several reasons (root document may already be closed, copy at a time when the new document is not open yet,...).

    This means that I have to remember all the layers and use them later.

    At the moment I am sth. Like this:

    ---------------------------------------------------------------------------------------

    public static std::vector < PIActionDescriptor > layeractions;

    Sub testGet()

    {

    Result PIActionDescriptor = NULL;

    numLayers Int32;

    SPErr error = kSPNoError;

    DescriptorTypeID typeID = 0;

    Int32 docCounter = 1;

    error = PIUGetInfoByIndex (docCounter,

    classDocument,

    keyNumberOfLayers,

    & numLayers,

    (NULL);

    If (numLayers > 0)

    for (int32 layCounter = 1;

    layCounter < = numLayers & & error == kSPNoError;

    layCounter ++)

    {

    error = PIUGetInfoByIndexIndex (layCounter,

    docCounter,

    classLayer,

    classDocument,

    0,

    and result,

    (NULL);

    layeractions.push_back (result);

    }

    }

    Sub testSet()

    {

    SPErr error = kSPNoError;

    Result PIActionDescriptor = NULL;

    for (auto & it: layeractions)

    {

    error = sPSActionControl-> Play (& result, eventMake, he, NULL);

    }

    }

    ---------------------------------------------------------------------------------------

    So what I'm doing, open a doc with some layers. Then testGet(), open new document then testSet().

    But bench always puts "the command 'Make' is not currently available." and error = - 128.

    Hope you get what I'm trying.

    Thanks for any thoughts!

    Who's going to be a difficult path to travel to this topic. Even if you can get all the properties of the active document and the layers within the document, you have not dealt with pixels on a normal layer data. You will need to save this broad as well. And for dynamic objects and linked smart objects... you have a job to do. Any topic of a document is not capable 'get '.

    Trying to cope with this: "document might already be narrow" would be almost impossible IMO.

    Remember, the source document, which is now closed I now want to copy. Then you can do:

    1. open closed source document. (Or make it more if it is already open)

    2. for each layer in the source document

    a. Select the layer

    b. copy of the document target

    3. close source document.

    The Get accessor routines are not for 'read' directly. You must get the interesting bits of information on and then use the game code that you found using listener.

  • I use Illustrator CC and sent a file to a colleague who uses CS6 where all the layers become a great layer.  How can I send it and preserve the layers?

    I use Illustrator CC and sent a file to a colleague who uses CS6 where all the layers become a great layer.  How can I send it and preserve the layers?

    coledang,

    Save a copy, and in the following options choose CS6.

    In this way, it should open correctly in CS6, and the original document is unscathed.

    You may find that some (new CC) features will not survive the downsaving.

    Edit: Hi SRiegel.

  • All my photos are displayed such as BW because somehow I saved a preset to quickly develop and it records in BW.  This is for all of my photos.  Individually, I can cancel their but did need help how to get rid of the pre-selection, so he's going to defau

    All my photos are displayed such as BW because somehow I saved a preset to quickly develop and it records in BW.  This is for all of my photos.  Individually, I can cancel their but need help how to get rid of the preset then all photos of goes to Default or in the shot. Thank you

    Go to the develop module and highlight all the images in the film at the bottom of the screen. Enable automatic synchronization, and then click the reset button. To reset all the images in your camera default settings.

  • E-mail allows you to see the most recent at the top, but now I have to look through all the emails to be received email today. How can I fix it?

    I DON'T KNOW WHY BUT MY MESSAGES IN MY INBOX ARE ALL MUDDLED UP.
    USED TO SEE THE MOST RECENT AT THE TOP NOW, I TUNED THROUGH ALL THE EMAILS TO FIND THE RECEIPT TODAY'S MAIL? Help, please.

    Steve is of course correct.  What mail client do you have?

  • How to navigate through all of the links in the links Panel in the user interface?

    Hello world

    I wonder how I can browse all the links in the links Panel, programmatically. I have a document where the resources present in this Panel are not available using the ILinkManager. He tells me there are no links in the document when using ILinkManager-> GetLinkCount().

    These resources are not more related to any element on the page. These are images which are not more related to what it is. Right-click on it and click on 'join the link' shows nothing in the document (the same operation on a resource that is linked to a graphic image focuses on it). I can manually re-edit the link, but nothing more.

    In the user interface, there is no way to delete (not menu 'remove' or whatever).

    I think I "created" them as follows: during the creation of the story, the story is tagged. Then I attach a picture frame and label it in the history. Then I remove the frame (s) containing the history, so that its history xml is "not placed" (see kXMLUnplaceCmdBoss). At this time (if I'm not mistaken), I created these inaccessible resources. I see the xml story unplaced in the structure of the document that remains not placed XML (in the backup store) and resources in the links Panel.

    History unplaced XML CAN be removed manually, but not these inaccessible resources. However, there must be a way, as InDesign can display them.

    How to reach these 'lost' resources and delete them, by programming?

    Independent of your real problem, I would first try the equivalent in the user interface.

    Preparation:

    To simplify things and make them visible, working on a traditional tale - not the backup store.

    The story should be labeled and will remain so.

    Add content as complicated as you want.

    Some content preceding and behind it must survive.

    Your content must be labeled - surrounded by a single label.

    Text-Select this unique tag (see the invisible etc for the right selection).

    Remove the text selection.

    See: Tags are gone, content text disappeared, the images have disappeared.

    Now find a way to perform this deletion text programmatically. Without specific code XML - operation but a simple text, InDesign will do the rest.

    Finally, use the code that results on the backup store.

  • How to get and set the length and the width of the content of the layer?

    How to get and set the length and the width of the content of the layer

    All layers are packed not equal. a layer as adjustment have no limits. Layer to smart object can have two different sizes. The size of the object and the size of the object may be transformed. All smart object layers have an associated transform. To transform a smart object layers you need to work with the size of the object the generated pixels fot the layer. Text layer can be resized with a transform or by changing the font size. Pixelated layers are resize via a transformation.  The script method is resize.  When you resize the number of pixelsits made by interpolation. You can specify what method to use or set Photoshop interpolation preferably by default.

    There is also a bug in Photoshop scripts if you pause the story said make a selection and use resize. Photoshop will properly support up to a State before where you suspended history. This bug seems to be in all versions of Photoshop.

    If you look ate the script in my bug report, you should get a good idea of how to resize a layer.

    Photoshop: Bug Script resize the rear paper folded to a history State

  • How to get rid of the spill on the edges of the document

    All I'm doing is getting rid of all spills in the course on the edges.  See below:

    clip mask.jpg

    I found a tutorial and it said to use a clipping mask.  So I called a box on the clip mask layer and did.  But what has happened is that it seems that all the layers are no longer the elements of individual layer - it's as if the clip mask off all the items on layers.

    Is there an easier way to do this?  I use Illustrator CS4 then please tell me how to do this in CC or a more recent version.  Thank you.

    Create a new layer. Move all other layers in as sublayers. Draw a rectangle on the top layer on top of all sublayers. Click the mark button mask in the layers panel.

  • Loop through all the items in a collection

    I need to loop through all the elements of a collection in a VB.NET program that uses the InDesign API. For example, I want to loop through all the pasta spread masters in a document. Here is my sample code:

    Dim I As Integer = 0

    Var MyApp as InDesign.Application = Nothing

    Var MyDoc as InDesign.Document = Nothing

    Var MyPage as InDesign.Page = Nothing

    MyApp = CType (Activator.CreateInstance (Type.GetTypeFromProgID ("InDesign.Application"), True), InDesign.Application)

    MyDoc = CType (MyApp.Documents.Add (False), InDesign.Document)

    With MyDoc

    With. DocumentPreferences

    . PageHeight = "8.5I".

    . PageWidth = "5.5i."

    Ends with

    With. ViewPreferences

    . HorizontalMeasurementUnits = InDesign.idMeasurementUnits.idPoints

    . VerticalMeasurementUnits = InDesign.idMeasurementUnits.idPoints

    Ends with

    If. MasterSpreads.Count > 0 Then

    For I = 0 To. MasterSpreads.Count - 1

    Dim ThisMasterSpread As InDesign.MasterSpread = CType (.) MasterSpreads.Item (I), InDesign.MasterSpread)

    Next I

    End If

    Ends with

    When it runs, I get an error on the last Dim statement which defines ThisMasterSpread. It highlights. MasterSpreads.Item (I) and gives the following error:

    COMException was unhandled: the Member required to the collection does not exist.

    How I managed to loop over all the pasta spread masters?

    Thank you!

    A lot of trial and error, I discovered the answer to my own question: the Collections are 1-based, not 0-based. My statement

    For I = 0 To. MasterSpreads.Count - 1

    should be

    For I = 1 To. MasterSpreads.Count

Maybe you are looking for