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

isolating a layer (hiding all other layers)

Community Beginner ,
Jun 03, 2011 Jun 03, 2011

I have started writing my first script but I am struggling to find out how to isolate an active layer.

Part of my script reads;

var doc = app.activeDocument;
doc.activeLayer = doc.artLayers.getByName('mk stone');

at this point I would like to hide all other layers in the document. I will then select one of the RGB channels then unhide the other layers.

I have worked out the selection part. So all I really need to know is how to hide and unhide all other layers.

Any help would be much appreciated.

TOPICS
Actions and scripting
1.2K
Translate
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
Adobe
Community Beginner ,
Jun 03, 2011 Jun 03, 2011

Do you know the layer name(s) that you want to show?

Translate
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 Beginner ,
Jun 04, 2011 Jun 04, 2011

There will be a number of layers to turn on and off.

The way it works is to create a folder and select a layer with the corresponding name. i.e create a new layerset called "stone set", then select an existing layer in the scene, this would be called "mk stone".

I would then select an individual RBG channel, load the selection and then make the "stone set" the active layer and apply the layer mask to the layerset.

I have got all this working fine. The only problem is when I try it with more than one layer because it just keeps seeing the highest up layer in the stack and reapplying these selections to all layersets.

I need to tell it to make "mk stone"  the only layer shown, make a RGB selection and then return back to the previous visibilty state. I would then apply the layer mask as previously mentioned select another layer "mk brick" hide all other layers make the RGB selection return to the previous visibilty state apply layer mask to the layerset etc....

It would be alot better if it could return to a previous visibilty state as some files I use have certain layers/layersets turned off and would be useful not to turn all these back on. If not I could work in an external file, but ideally in the same. What I really need is exactly the same as 'alt' clicking the the eye icon on a layer and 'alt' clicking to return to the previous state.

Hope this makes sense. Many thanks for any help.

Translate
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 ,
Jun 04, 2011 Jun 04, 2011

if the layer in question is active you could try (and run it afterwards again to show the other layers again):

// =======================================================

var idShw = charIDToTypeID( "Shw " );

    var desc4 = new ActionDescriptor();

    var idnull = charIDToTypeID( "null" );

        var list1 = new ActionList();

            var ref3 = new ActionReference();

            var idLyr = charIDToTypeID( "Lyr " );

            var idOrdn = charIDToTypeID( "Ordn" );

            var idTrgt = charIDToTypeID( "Trgt" );

            ref3.putEnumerated( idLyr, idOrdn, idTrgt );

        list1.putReference( ref3 );

    desc4.putList( idnull, list1 );

    var idTglO = charIDToTypeID( "TglO" );

    desc4.putBoolean( idTglO, true );

executeAction( idShw, desc4, DialogModes.NO );

Translate
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 Beginner ,
Jun 04, 2011 Jun 04, 2011

Hi  c.pfaffenbichler,

I had played around with the Scriptlistener Plugin and got the same code. Only the first time I gave up with it not knowing what to do with the code. It was after you giving the same code that I thought it must be right and played around with it until putting it into a function. Slowly learning new bits hear and there and always grateful for a little help a long the way,

Thanks again.

Translate
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 Beginner ,
Jun 06, 2011 Jun 06, 2011
LATEST

To hide all layers but the selected layer.


// hide all layers

for(var i=0; i<doc.layers.length; i++){

    doc.layersvisible = false;

}

var mkStoneLayer= doc.artLayers.getByName('mk stone');

mkStoneLayer.visible = true;

Translate
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