Page 1 of 1

Show/Hide layers with script

Posted: Wed Nov 29, 2017 11:23 pm
by dfriasb
Hello all,

I'm using

Code: Select all

layer.setFrozen(true)
and

Code: Select all

layer.setFrozen(false)
in two scripts to hide/show some layers with certain names. You can download the attached .js files with the scripts and one test drawing to verify try them if you want. The two commands should have the commitment of hiding or showing all layers whose names are starting with "0" and having one or two additional characters after (so maximum 3 characters layer names). You can try them by command line typing "ch0off" or "ch0on".

The thing is, right now, this two scripts are only partially working. If I hide "manually" one of these layers clicking on the visibility switcher (eye icon) on the Layer List, then the command "ch0on" is not working. The same thing happens if I isolate another current layer with Y,O; after that "ch0on" doesn't work.

About "ch0off", seems it's working as expected in any case.

I guess I'm misunderstanding the behaviour of

Code: Select all

layer.setFrozen(false)
. So, which is the variable I should use?

I also would like to create another script to isolate all layers starting with "0" as well.

Thanks for your support. Best regards,

David

Re: Show/Hide layers with script

Posted: Thu Nov 30, 2017 11:10 am
by andrew
There are two states that influence a layer's visibility: frozen and off.

My suspicion is that you might be switching a layer off in the layer list and freezing it in the script.

First, you might want to show both states in the layer list as follows:
Edit > Application Preferences > Widgets > Layer List > Show frozen column

Notes:
If a layer is frozen, block references on that layer are not shown.
If a layer is off, block references are still shown.
Layer "0" might behave differently depending on preferences in Edit > Application Preferences > Layer > Compatibility.