Script request to toggle the visibility of the multiple layers using regex

Hello

I did a ton of research, trail / error and need to reach out for help.

I'm trying to create a PS script that activates / deactivates the visibility of the layers AND groups based on a regular expression in a PS document.

EXAMPLE GROUP PS & LAYERS STRUCTURE

=======================================

• / / example

• header

-some layers

-/ / test

• footer

-another layer

-/ / content area

Bullet = group

Hyphen = layer


This script should hide the two "/ / example", "/ / test ', and ' / / content area ' on track. Ideally, the script would reveal these layers and groups.


I managed to find two scripts that make each half of the result you want below.

Part 1: Use of regular expressions to locate each layer and the Group (I changed the reg exp for use cases):

Re: Script to search for layer names

by: Michael L Hale

var re = /-/-/. * / ; corresponds to a reg exp var = collectNamesAM (re); Download the table of correspondence of layer indexes for (var l = 0; l < matches.length; l ++) {makeActiveByIndex (matches [t], false);   do something with layer alert (app.activeDocument.activeLayer.name); } / / next match if no function collectNamesAM (re) {var allLayers = new Array();   var startLoop = number (! hasBackground());   var endLoop = getNumberOfLayer();   for (var l = startLoop; l < endLoop; l ++) {if (! isValidActiveLayer (l)) {l ++;}}   } If (match (re) getLayerNameByIndex (l)! = null) {allLayers.push (l);   allLayers return}}; }; / * / / / / / Function: getActiveLayerIndex / / Description: Gets Gets the index of the Action Manager API / / to activeLayer corrected for background layer / / use: var idx = getActiveLayerIndex();  Entry: No / / Return: number - correct AM itemIndex / / Dependices: hasBackground / / / * / function getActiveLayerIndex() {var Ref = new ActionReference();   ref.putProperty (1349677170, 1232366921);   ref.putEnumerated (1283027488, 1332896878, 1416783732);   var RES = executeActionGet (Ref) .getInteger (1232366921) - number (hasBackground()).   RES IS 4? RES ++: res / / why the skip in this doc?    return res; } / * / / / / / Function: (isValidActiveLayer) / / Description: LayerSection checks for the "real" layers / / use: if (isValidActiveLayer()) / / entry: no / / return: Boolean - True if this is the end of a game / / Notes: not necessary if the layer has been made active / / using the Action Manager API / / / * / function isValidActiveLayer (idx) {var propName = stringIDToTypeID ("layerSection"); / / cannot replace var ref = new ActionReference();}   ref.putProperty (1349677170, propName); TypeID to "Rprp" / / "Lyr", idx ref.putIndex (1283027488, idx); ""   var / / desc = executeActionGet (ref);   type var = desc.getEnumerationValue (propName);   var RES = typeIDToStringID (type);   return res == "layerSectionEnd"? false: true; }; / * / / / / / Function: hasBackground / / Description: bottom layer using AM API Test / / use: if (hasBackground());  Entry: No / / return: Boolean - true if a background layer doc / / Notes: requires that the document be active / / DOM: App.Document.backgroundLayer / / / * / function hasBackground() {var res = undefined;   try {var Ref = new ActionReference();   ref.putProperty (1349677170, 1315774496);   ref.putIndex (1283027488, 0);   executeActionGet (ref) .getString (1315774496);   RES = true;   } catch (e) {res = false} return res; }; function makeActiveByIndex (idx, forceVisible) {try {var desc = new ActionDescriptor();}   Var ref = new ActionReference();   ref.putIndex (charIDToTypeID ("Lyr"), idx) desc.putReference (charIDToTypeID ("null"), ref);   desc.putBoolean (charIDToTypeID ("MKV"), forceVisible);   executeAction (charIDToTypeID ("TPCV"), desc, DialogModes.NO);   } catch (e) {return-1 ;}} ; function getNumberOfLayer() {var Ref = new ActionReference();   ref.putEnumerated (charIDToTypeID ("Dcmn"), charIDToTypeID ("Ordn"), charIDToTypeID ("Trgt"));   var / / desc = executeActionGet (ref);   var numberOfLayer = desc.getInteger (charIDToTypeID ("NmbL"));   Return numberOfLayer; }; function getLayerNameByIndex (idx) {var Ref = new ActionReference();   ref.putProperty (charIDToTypeID ("Rprp"), charIDToTypeID ("Nm"));   ref.putIndex (charIDToTypeID ("Lyr"), idx);   Return executeActionGet (Ref) .getString (charIDToTypeID ("Nm")) ;} ;

This script shows an alert for each layer / group name that corresponds to-is to find the layers / groups!

Now I need the layers / groups to simultaneously show or hide depending on their status.


I found a script that toggles the visibility of a specific name (in this case "GRID") here:

Photoshop-grid-enable/disable/turn Grid.jsx to master · squarefrog/photoshop-grid-toggle · GitHub

var gridName = "GRID"; Implement what you call your grid layer together. function toggleGridLayer() {if (app.documents.length > 0) {var gridLayer = app.activeDocument.layerSets.getByName (gridName);}}         gridLayer.visible =! gridLayer.visible;     toggleGridLayer()}};

Essentially, I want to merge the tilting head of visibility script in the script of the regular expression. Any help would be great. Thanks in advance!


Note: The use of CC PS 2015

This script is all on one line and hard to see where are the separate lines. If you want the code to turn on or off a layer, you can use:

var docLayer = app.activeDocument.activeLayer;
docLayer.visible=docLayer.visible==false;

Tags: Photoshop

Similar Questions

  • Change the multiple layers at the same time

    Hi all
    Is it possible to change the position of the multiple layers at the same time? that is to say: I've got a slideshow made with several layers (probably about 60) while back and now I need to re use it in a different size (smaller). When I just resize the document, my slide is no longer in the center of it and is bigger. I would like to: 1. change its position within the document. 2 reduce entire layer together. If 2 is not possible, fine, but to me, there may be a way to change its position. Thank you much for the help!

    If you look at the area where Flash displays your frames per second is a small button (it looks like 2 boxes blu - ish overlapping). It is the button "edit multiple layers. Once you press this, you will see a marker on your time line asking you to select the images to change. Stretch this segment to cover all the images you want to include in your editing - lock all layers you want to include in your installation. Then, you can press Ctrl + a to 'select all' - this will only select executives in "onion" and unlocked frames - from there, any changes will not affect what is selected. You have to play with how it works because it can be a little difficult to understand (when it comes to points of alignment and balance, etc.). I would like to make a copy of your flash document to test this point until understand you before you start your original edition.

  • Wiggle of the multiple layers

    im working on a project and I want all the layers together waving as it was 1 layer...

    But if I try to put them all to shake they don't move exactly the same thing... is there a way to do this?

    Hello! im working on a project and I need it fast! im stuck at the wiggle expression. I want to move several layers in 1 layer, but I can't seem to go together... they move only mismatch... is it possible to do this? Ive been looking f

    Wiggle a layer then parent of all the other layers to the one you shake.

  • How to get the multiple layers of data

    Hello

    I imported two jpg files into a single composition. Please follow this procedure...

    1 created a composition, say his name testCompo

    2 imported a file1.jpg in the file-> Import-> file draft

    3 imported a file2.jpg in the file-> Import-> file draft

    4. drag the two files, file1.jpg and file2.jpg, in the testCompo

    Now, I have two layers (it is file1.jpg and nested are file2.jpg) in my testCompo. How can I get the information in pixels or pixel data of the

    the two images (IE, I mean layers).

    I knew that params [0]-> u.ld is the first data layer in

    () EntryPointFunc
    PF_Cmd cmd,
    PF_InData * in_data,
    PF_OutData * out_data,.
    PF_ParamDef * params [],.
    PF_LayerDef * output,
    void * extra)

    So what about other data layer? Then, finally how can we get the multiple images/layers data in AE?

    Thanks in advance!

    It's the thing.

    You must have a param layer (let's say it's param number 3).

    Use this param to select any layer of the model.

    Now you checkout param 3.

    what you get is a paramDef structure containing the pixels of the layer 3 Advanced param to.

    you will find this information at:

    paramDef-> u.ld.data (or something close to that. I do not have in front of me)

    This way the jpg1 affect can get jpg2 pixels and jpg3. any layer in the comp.

  • The invisible layers using the text returned on visible layers

    I'm working on a newsletter page 8 for a customer. There are 5 versions of the newsletter of new pages 3-6 are common to all the 5 editions, pages 1-2 and 7-8 is unique to each version. I use an InDesign document with 6 layers, 1 layer of background (#1) pour common/story layouts and a separate layer for each version (#2-#6). When laying on the stories of page 7 (a single page) my invisible layers affect the provision on visible layers. I have a story on layer #2 all plotted, so when I move to the layer #3 I disable #2 and light #3 which should give me a blank page to work with. The page appears empty, but when I add my pictures and text, information on layer #3 is being moved by what looks like a build-up of layer #2. Why is this invisible layer affecting the layout on a visible layer? How do I fix this so I don't have to go back and rebuild individually 5 versions? Thank you!

    It is exactly as expected. If you want to disable, open the properties of the layer of hidden layers, and it can be.

  • Script to automatically replace the specific layers?

    Hello. I work for a small company and we frequently get client files I need to edit. Because of the way thay are formatted the layers always come with the same name/structure, but they still have a layer we need to replace. Go to a shared drive and manually place our desired element (a .pdf file if it is of importance) in the subset to continue with the file layer. Thus, for example, there will be a layer in the default file named layer 1, and this layer is Group 1 > Group > mask of clipping and Image.

    I know ideally we should simply fix the script that formats the layers, but for now is not possible. So what I would like to be able to do (assuming that it is still possible), is to have a script that we can run that automatically replaces the 'Image' file in these layers of subset, I spoke with a file to a location on a local computer (for example replace the 1 layer > Group 1 > Group > image.jpg with C:/example/example.pdf).

    I searched online and could not find anything, so I thought that I have turned to the community for help. Entries, suggestions or creative solutions would be greatly appreciated! And as always, thanks, everyone on these forums is usually very beautiful and impressive, so it's always nice to come here to help.

    Glad to see that you have accepted the challenge.

    Well, this should help you get started. Keep in mind, it is written in VB.NET then you will need to translate it is that you want in Javascript. At least you will have a model to begin with. This is just a quick hack for you to start with - you may need to change the layer you want the new image appears on, if it's important. In addition, it is assumed that you started with a plot point (image.jpg) and whether you want the new image to be incorporated. You will see the code tweak as you wish.

    Var app As Illustrator.Application = CreateObject ("Illustrator.Application")

    Dim aDoc as long as I. Document = app. ActiveDocument

    For each item in aDoc.RasterItems

    If the element. Name = "image.jpg" Then

    order of the day. Selected = True

    Dim newPlacedItem As AI. PlacedItem = aDoc.PlacedItems.Add

    newPlacedItem.File = "YourNewFilePathHere.pdf".

    newPlacedItem.Embed)

    order of the day. Delete()

    End If

    Next

    I hope this helps.

    -TT

  • The multiple layers activation or deactivation

    Does anyone know if there is a way to turn several layers on or off massively in Illustrator CC?

    I thought that to see a video demonstration of this at some point. Select the desired layer names and use a combination of shortcut keys - or something like that.

    Thank you

    Don

    while now the key shift-keys ALT...

    Just Alt/Option, no need to change.

  • How to separate the layer in the palette layers using the color?

    How can I separate the layer in the layers palette using color to increase the visualbility like the image below?

    layer palette.JPG

    You could right click on the eye in the thumbnail of the layer

    or in the layer Panel dialog box, select layer/group properties.

    MTSTUNER

  • masking of the multiple layers with a mask

    Is it possible to do?

    When I place the template files to tell... thumbnail images with rounded corners and a drop shadow, I preffer to proceed in the way that Photshop and imagready allow you to do > creat a form and use it to hide any layers above it. That way if I chose to do one or two pixels wide, I've just made it to the mask layer and resave the tumbnails outside. As far as I can tell made Fireworks you create a different mask for each layer, so you'd have to change it in each layer... not the best workflow!

    Thanks for any help on this.

    for me it's using 1 layer mask with 1

    a symbol that contains several layers of images. I can spend the layers to display the active image, I want to show

    Benefits

    1. use only 1 layer mask

    2 can group images into a symbol

    3. can you share other sets of images as symbols

    4. can I apply effects to the mask layer either STROKE / shadows

    I hope that this workflow can also help you

  • Accept the terms of use

    When you try to sign live account to the security settings for the direct family indicated by the terms of use have not been addressed or accepted. I accept the terms of use?

    Hello

    I am happy to assist you on your request regarding accepting the terms of use for the safety of the family. You can make these changes by following the steps below:

    1. open your browser and go to family safety.

    2 sign in using the Windows Live ID Admin and the password

    3. the terms of use must be displayed and you can accept the

    4. Once you have accepted the terms of use, then try to connect to the FSS client

    Let us know the results later.

    Thank you.

  • Photoshop CC Auto-possibilite select the hidden layers

    Hi, I am not sure if this is a bug or what... When I click on and drag with the move of the automatic selection of the multiple layers tool, it will not select only the layers that I wanted, but also layers hidden in the same area of my selection (or at least, layers, which are in the hidden groups).

    For example, say I have a layer group. I duplicate the group, and then make the original group invisible so that I can create an alternative version. When I clock and drag to select the objects in the new group, the (hidden) in the former group objects get selected as well, so I'm obliged to selection click on every article I want to change... forever.

    This is different from all previous versions of PS and a big trouble.

    If someone else can confirm this bug, or is it just me? Or not consider you this as a bug? I see some specific cases where it can be useful, but I would like to control this behavior as a preferece. Maybe there is already a preference for this problem and I just have not found. Any comments would be more useful

    See you soon,.

    Cory

    Discussing this bug here:

    http://forums.Adobe.com/message/5423270#5423270

  • Need a script to help to toggle the visibility of the BCG

    I need the ability to toggle the visibility of the OCGS in a PDF file. Someone at - it a sample script of how do? I would use a button to toggle between visible and hidden. Below is a diagram of fence that my boss is to make sure the sections can be hidden to reveal the section behind. I know I can do it in the layers panel, but he wants it to be by a button.

    Picture 1.png

    To illustrate this to yourself, download the example file to open it in the article and add a new button. Use the following as a MouseUp the button script:

    Toggle LayerOne

    BCG var = FindOCG ("LayerOne");
    OCG. State =! OCG.State;

    This code relies on the FindOCG function defined in the JavaScript at the level of the document in the file. You can use the same function and the same code above in your document.

  • I use the free trial version. I try to print an Applitrack online application. He said that I should print preview it.  It does not work.  How can I get it works. Help.  I'm afraid that my request will be not visible to employers.

    I use the free trial version. I try to print an Applitrack online application. He said that I should print preview it.  It does not work.  How can I get it works. Help.  I'm afraid that my request will be not visible to employers.

    If it is an Acrobat, who never had a print preview, because the PDF screen is an overview of what the prints.

  • Is it possible to toggle the setting panel open a closure with a combination of keys?

    Is it possible to toggle the setting panel open a closure with a combination of keys, or y at - it a script that can do?

    adjustmentPanel.jpg

    Try this instead:

    Go to Edit/shortcuts...

    Then where it says "shortcuts to: ', pull down the menu drop down and select"request Menus.

    Then expand the category of 'Window' and from there to the bottom, you will find 'Properties' - give a keyboard shortcut.

    This might work

  • I tried to write a script, the user can use. This return number file *.tiff associations back using the image viewer is caused each month.

    Original title: automation of file tiff without elevated rights association

    I tried to write a script, the user can use. This return number file *.tiff associations back using the image viewer is caused each month.

    Hi, Unclemarcus2002,

    You would be wiser to post on the Forum TechNet where there is COMPUTER experts.

    http://social.technet.Microsoft.com/forums/en-us/newThread

    Maybe using the ASSOC and FTYPE command in a script will do what you want? I think that these orders would also apply the association throughout the world, rather than on a per-user basis.

    ASSOC: http:

    FTPYE: http:

    Here is an example, that you can try.

    Let's say you have a text file called "foo.bar" and you want the extension .bar always open with Notepad. There is an association for text files, so get him by typing "Ftype | more' at the command prompt (it will make a major announcement). Finally, you'll see the line "txtfile". On mine, it's "txtfile=%systemroot%\system32\notepad.exe %1" without the quotes.

    First create your association: assoc .bar = FooBarText

    Now to assign your request to your file type association: ftype FooBarText=%systemroot%\system32\notepad.exe %1

    You should now be able to double-click the foo.bar file and it will automatically open in Notepad.

    If you already have a Microsoft Office Document Imaging association, I think that it should be relatively simple type of substitution. Use ftype /? for a little more help.

    http://community.Spiceworks.com/topic/119639-Windows-7-automate-file-assocations

Maybe you are looking for

  • I've never seen the cloud on my watch symbolizing the wifi connection.

    I've never seen the cloud on my watch symbolizing the wifi connection. How to operate when phone and shows are on the same network?

  • How can I get rear switchable graphics?

    I recently downloaded an update of the AMD driver. He removed the switchable graphics option and I spent hours searching the Internet on how to get it back. I can't find any drivers or anything to get it back. Also, after I did my Sony Vegas will not

  • Memory and the disk presents 99% usage in Task Manager

    Its been like a month that my task manageris showing disk and memory utilization to 99% high skyrocketing even if I'm only n opening three navigation tabs. And the system will be late time... I anitivirus install n that's far too... What would be the

  • my laptop keeps restarting after the installation of updates

    my laptop is stuck at step 3 of 3 (only display 0% complete) after the reboot for updates, then restart again and again, with the same supposed progress, I ve let it doesn't restart on 7 times.still no good. Tell me what are the steps to solve this p

  • printing for design jet 430 cable

    DESIGN JET 430 (BLACK, NO COLOR PRINTING) ALLOWS YOU TO PRINT WITH A PRINTER ADAPTER USB FROM THE PARALLEL CABLE? I SEE ON AMAZON DIFFERENT SOLUTIONS: (1) USB 2.0 - IEEE 25 POLES DB25 PARALLEL ADAPTER (2) USB 2.0 - PARALLEL IEEE 1284 36 LPT ADAPTER P