• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Hide/Show specific layers

New Here ,
Oct 25, 2013 Oct 25, 2013

Copy link to clipboard

Copied

Hi,

How can I Hide specific layers and then show one layer?

Im making a pannel with configurator 4 to help me with some things.

what I would like to do is, I have some layers and I want to show only one of them.

Example:

I have these groups in my psd file

-Overlays

     -Overlay 1

     -Overlay 2

     -Overlay 3

     -Overlay 4

     -Overlay 5

     -Overlay 6

     -Overlay 7

     -Overlay 8

     -Overlay 9

And I need to have them all off exept one. But i dont want to effect the other layers in my psd.

TOPICS
Actions and scripting

Views

6.5K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guru , Nov 05, 2013 Nov 05, 2013

function showLayerSet( setName ){

    // still need a known layer structure

    var overlaySet = app.activeDocument.layerSets.getByName('Overlay Icon').layerSets.getByName('overlayicon');

    // loop all the layers in the main layerSet

    for( var setIndex = 0;setIndex<overlaySet.layerSets.length;setIndex++){

        if(overlaySet.layerSets[setIndex].name == setName){

            overlaySet.layerSets[setIndex].visible = true;

        }else{

            overlaySet.layerSets[setIndex].visible = false;

   

...

Votes

Translate

Translate
Adobe
Community Expert ,
Oct 25, 2013 Oct 25, 2013

Copy link to clipboard

Copied

MrSchieska schrieb:

… I have these groups in my psd file

-Overlays

     -Overlay 1

     -Overlay 2

     -Overlay 3

     -Overlay 4

     -Overlay 5

     -Overlay 6

     -Overlay 7

     -Overlay 8

     -Overlay 9

You better show us a screenshot of your layers palette.


Which version of PS?

Perhaps you mean something like this:

(Make sure that a layer group is active.)

// layerSetShowIfActive.jsx

// http://forums.adobe.com/message/5788938#5788938

// shows only the active layer set (other invisible)

// regards pixxxelschubser

if (activeDocument.activeLayer.typename == 'LayerSet' ) {

    var aSet = activeDocument.activeLayer.name;

    var desc = new ActionDescriptor();

    var list = new ActionList();

var ref = new ActionReference();

    ref.putName( charIDToTypeID( "Lyr " ), aSet );

    list.putReference( ref );

    desc.putList( charIDToTypeID( "null" ), list );

    desc.putBoolean( charIDToTypeID( "TglO" ), true );

executeAction( charIDToTypeID( "Shw " ), desc, DialogModes.NO );

if (activeDocument.activeLayer.parent.typename == 'LayerSet' ) {

    activeDocument.activeLayer.parent.visible = true;

    }

    } else {

        alert("No active Layer Set");

        }

Is this helpful?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 27, 2013 Oct 27, 2013

Copy link to clipboard

Copied

Not realy wat i meen.

example.png

I would like a script to toggle all the overlay layers off and than toggle on just one.

So there would be only one layer on at the time.

I am going to use it in a photoshop panel so our non design staff can do some of the repeditive work.

needs to work on photoshop cs6 and up

Message was edited by: MrSchieska

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 27, 2013 Oct 27, 2013

Copy link to clipboard

Copied

The world could be so easy.

Be sure, that the document structur is always the same and one Overlay-Set is the active layer.

// layerSetShowIfOverlayNumActive.jsx

// http://forums.adobe.com/message/5788938#5788938

// shows only the active "Overlay+number" layer set (other invisible)

// regards pixxxelschubser

var aDoc = activeDocument;

var aLay, actLay;

var aLayerSet = aDoc.activeLayer.parent; // overlayicon

if (aLayerSet.typename == 'LayerSet' && aLayerSet.name == "overlayicon" ) {

    aLay = aLayerSet.layers; actLay = aDoc.activeLayer;

    for (i = 0; i < aLay.length; i++) {

        if (aLay.name != actLay.name) {

        aLay.visible = false;

        } else {

            aLay.visible = true;

            }

        }

    } else {

        alert("No active Overlay-Set");

        }

Have fun

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 30, 2013 Oct 30, 2013

Copy link to clipboard

Copied

@MrSchieska,

where are your manners?

The complaint that the first script is not working as desired, arrived very quickly:

MrSchieska schrieb:

Not realy wat i meen …

… I would like a script to toggle all the overlay layers off and than toggle on just one …

Now the script seems to work, but you give no feedback. Why not?

If your problem is solved, then simply mark the thread as correct (by clicking on „correct“ when you're logged in). Then the thread gets a green speech bubble as sign for a solved question.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Oct 30, 2013 Oct 30, 2013

Copy link to clipboard

Copied

I agree that the op could have supplied more details about what the script should be but the script posted doesn't meet all the requirements of the screenshot. So that may be why it is not marked as correct. That is the activeLayer is not one of the overlay layerSets.

The script below doesn't require a overlaySet be active. It does require the layer structure in the screenshot.

var overlaySet = app.activeDocument.layerSets.getByName('Overlay Icon').layerSets.getByName('overlayicon');

for( var setIndex = 0;setIndex<overlaySet.layerSets.length;setIndex++){

    if(overlaySet.layerSets[setIndex].visible){

        if(setIndex == overlaySet.layerSets.length-1){

            overlaySet.layerSets[setIndex].visible = false;

            overlaySet.layerSets[0].visible = true;

        }else{

            overlaySet.layerSets[setIndex].visible = false;

            overlaySet.layerSets[setIndex+1].visible = true;

        }

        break;

   }

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Oct 30, 2013 Oct 30, 2013

Copy link to clipboard

Copied

Michael L Hale schrieb:

I agree that the op could have supplied more details about what the script should be …

Hi Michael L Hale,

I agree with you completly.

All helpers unfortunately needs the „magical look into a crystal ball“ to often. (I hope this is the correct translation)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 05, 2013 Nov 05, 2013

Copy link to clipboard

Copied

pixxxel schubser wrote:

@MrSchieska,

where are your manners?

Sorry I haven't been focusing on work this passed week got hit by a car and broke my leg at 3 places. but anyway im back

Sorry but still not what I mean but verry clever piece of code and i realy apriciate it.

Ill try to explain it differently.

I am making this panel in adobe configurator 4

That our non grapical staffmembers can use to change files.

I don't want them to touch the layers because that leeds to mistakes.

So instead of the layerpanel they would have this panel.

Naamloos-1.jpg

What I would like is some photoshop script to put behind the first button.

And than I think I would be able to edit the script for the rest of the buttons.

so a script that does:

turn off if on:

     -Overlay 1

     -Overlay 2

     -Overlay 3

     -Overlay 4

     -Overlay 5

     -Overlay 6

     -Overlay 7

     -Overlay 8

     -Overlay 9

     -Overlay 10

     -Overlay 11

     -Overlay 12

     -Overlay 13

     -Overlay 14

     -Overlay 15

turn on:

     -Overlay 1    

Hope This helps...

sorry for the inconvenience

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Nov 05, 2013 Nov 05, 2013

Copy link to clipboard

Copied

function showLayerSet( setName ){

    // still need a known layer structure

    var overlaySet = app.activeDocument.layerSets.getByName('Overlay Icon').layerSets.getByName('overlayicon');

    // loop all the layers in the main layerSet

    for( var setIndex = 0;setIndex<overlaySet.layerSets.length;setIndex++){

        if(overlaySet.layerSets[setIndex].name == setName){

            overlaySet.layerSets[setIndex].visible = true;

        }else{

            overlaySet.layerSets[setIndex].visible = false;

        }

    }

}

showLayerSet( 'Overlay 1' );

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 05, 2013 Nov 05, 2013

Copy link to clipboard

Copied

LATEST

Thanks that exactly what I need.

Special thanks to:

pixxxel schubser

Michael L Hale

you guys rule!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines