Show/Hide layers with script

Use this forum to ask questions about how to do things in QCAD.

Moderator: andrew

Forum rules
Always indicate Operating system, QCAD version
Attach Drawing files, Screenshots
User avatar
Full Member
Posts: 64
Joined: Thu Mar 10, 2016 1:08 pm
Location: Calafell, Tarragona, Spain

Show/Hide layers with script

Postby dfriasb » Wed Nov 29, 2017 11:23 pm

Hello all,

I'm using

Code: Select all


Code: Select all

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

. 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,

sample drawing to test these commands
(1020.77 KiB) Downloaded 8 times
scripts for the two commands
(3.29 KiB) Downloaded 11 times
David Frías Barranco | architect |

User avatar
Site Admin
Posts: 5232
Joined: Fri Mar 30, 2007 6:07 am

Re: Show/Hide layers with script

Postby andrew » Thu Nov 30, 2017 11:10 am

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

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.

Return to “QCAD 'How Do I' Questions”

Who is online

Users browsing this forum: No registered users and 3 guests