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

Selecting Only Visible Layers

Guest
Jan 09, 2013 Jan 09, 2013

I am a beginner scripter trying to find a way to hide all the layers in a document.  The document has hundreds of layers so selecting all and then hiding all takes way too long to run.  Is there a way to simlply hide all or select only the layers that are visible and then hide?

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

correct answers 1 Correct answer

Valorous Hero , Jan 09, 2013 Jan 09, 2013

Here is one way to turn all layers visibility off ...

//select top layer

activeDocument.activeLayer = activeDocument.layers[0];

//toggle all other layers visibility off

toggleVisability();

//toggle this layers visibility off

activeDocument.activeLayer.visible=false;

//This function is the same as Alt/Click on a layers eye

function toggleVisability() {

var desc = new ActionDescriptor();

var list1 = new ActionList();

var ref = new ActionReference();

ref.putEnumerated( charIDToTypeID('Lyr '),charIDToTypeID

...
Translate
Adobe
Valorous Hero ,
Jan 09, 2013 Jan 09, 2013

Here is one way to turn all layers visibility off ...

//select top layer

activeDocument.activeLayer = activeDocument.layers[0];

//toggle all other layers visibility off

toggleVisability();

//toggle this layers visibility off

activeDocument.activeLayer.visible=false;

//This function is the same as Alt/Click on a layers eye

function toggleVisability() {

var desc = new ActionDescriptor();

var list1 = new ActionList();

var ref = new ActionReference();

ref.putEnumerated( charIDToTypeID('Lyr '),charIDToTypeID('Ordn'),charIDToTypeID('Trgt') );

list1.putReference( ref );

desc.putList( charIDToTypeID('null'), list1 );

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

executeAction( charIDToTypeID('Shw '), desc, 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
Guest
Jan 09, 2013 Jan 09, 2013

Thank you sir.

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
Enthusiast ,
Aug 18, 2013 Aug 18, 2013

is there a way to do this so that it turn all layers 'ON' instead of 'off' ?

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
Guru ,
Aug 18, 2013 Aug 18, 2013
LATEST

function showAllLayers() {

    var numberOfLayers = getNumberOfLayer();

    var desc = new ActionDescriptor();

    var list1 = new ActionList();

    var ref = new ActionReference();

    for(var layerIndex=1-Boolean(hasBackground());layerIndex<=numberOfLayers;layerIndex++){

        ref.putIndex( charIDToTypeID('Lyr '), layerIndex );

    }

    list1.putReference( ref );

    desc.putList( charIDToTypeID('null'), list1 );

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

};

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 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;

};

showAllLayers();

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