zscript for layers


i just have a few questions :

  1. I want to ask how should be look a script or macro for resetting all layers to 0 ?

  2. Also how should be look a script or macro for resetting the first 8 layers to 0 , then the other 8 to 0 and etc?

  3. And the last one how should be look a script or macro for recording all layer values and the same for paste all this recorded values to the all layers

Thanks so much , i will be really appropriate if somebody can help me on this …

Layers are quite tricky, especially if you don’t know the Layer names. If the layers don’t have names, or have the same names, then some things won’t work.

If everything is fixed, and you know the layer names, you can simply adjust the scrollbar and then set the layer. The scrollbar can be set to the top by using the number of layers minus 1, so if you’ve got 16 layers then:

[ISet,Tool:Layers:Layers Scrollbar,0,15]

will set it to the top. You need to adjust the scrollbar so that the layers you want are visible. Then you can simply set a layer using its name:


Once you set all those eight layers then you’d just subtract 8 from whatever the scrollbar is set to so that the next eight layers show:

[ISet,Tool:Layers:Layers Scrollbar,0,7]

Anyway, if you don’t know the layer names you have to find them as you go. This means you have to step up or down the layers using the SelectUp or SelectDown buttons. This isn’t very fast but it is the only reliable way of doing it (that I’ve found).

I’ve attached a script that demonstrates the method when you don’t know the layer names. Load it using the Load button in the ZScript palette and then press ‘H’ on the keyboard. You should then see the two buttons in the section at the bottom of the interface.

There are two buttons. The TurnOff button turns off all the layers and stores their intensity values. The TurnOn button resets the layers. In both cases the layer that was selected at the start is reselected.

I’ve not included turning off the first eight layers. This won’t be difficult to do but it depends a little on what you want to happen.

Is this for your ZBuilder? If so, I can help make a plugin rather than relying on macros. Send me a PM if you want to discuss privately.

SetLayers.txt (3.53 KB)SetLayers.txt (3.53 KB)

Hi Marcus,

Thats a very useful script. However it seems to be slow when turning off all the layers and turning back on again. I find it faster to manually hide all layers and the turn on button of your script unhides them much faster, so it has at least cut out the process of turning the layers back on again. Is there a way you can make the turn on button into a plugin so I can drag it onto my UI? cheers

Try this. I’ve changed some code to speed things up - it works fine for me but it might not for you, so let me know. If this works I might extend it a bit to include a few other utilities.

Unzip the file and drop the LayerTools4R8.zsc file into the ZStartup/ZPlugs64. Restart ZBrush and you will have a new “Layer Tools” sub-palette in the Zplugin palette.

LayerTools4R8_02.zip (2.04 KB)LayerTools4R8_02.zip (2.04 KB)

Thanks Marcus for taking the time to do that :slight_smile: I tied it but it doesn’t seem to work. turning layers off or on. My ztool has 7 subdivisions not sure if that makes a difference?

OK, thanks, that’s disappointing. It shouldn’t make any difference how many subdivision levels there are, except for heavy meshes at the top subdivision level it will be slower. Note that all this does is turn the layer visibility on or off. It doesn’t change the Layer Intensity, so if that’s at 0 you won’t see any difference.

Darn that sounds perfect! Its the visibility I want turned on and off. I tried it on a sphere with a couple of layers though still nothing happens when I press on or off. Is it working all good at your end?

Yes, it was working. But I think I found what was wrong. Try the new version - LayerTools4R8_02 - which I’ve added to the post above.

Hey Marcus, great! I will try the new script now and report back :slight_smile:

Oh wow! That’s much better! :slight_smile: Thanks so much for that Marcus! This saves me heaps of time having to trudge though turning off each layer when editing the base model and it is really fast. This is the best zbrush tool I have downloaded ever :smiley: cheers!

That’s great, thanks for letting me know!

This is really handy Marcus!

One thing that I’ve found with layers is that turning them on or off at any sub d level except for your highest sub d level will cause issues on your mesh. Is it possible to get a version of this that auto goes to each subtools highest sub d level before turning on or off the layers?

If the above is easy enough, it would also be extremely awesome to have the ability to run this on all and/or visible subtools.

If you don’t feel like you have the time to mess with it, I’d be happy to take a crack at it if you feel like sharing the latest source code. I’ll be sure to share it back when/if I can solve it. :smiley:


Thanks Eric!

Here’s a revised version with the layers turned on/off at the highest subdiv, and options for Selected, Visible or All subtools.

LayerTools4R8_03.zip (2.8 KB)

Let me know if you encounter any problems!LayerTools4R8_03.zip (2.8 KB)


This is tremendous Marcus! Thank you! Works perfectly!

Hey Marcus,

I get the following error when trying to run this tool on zbrush 2018.1 on Windows.

Any thoughts?

Thanks :slight_smile:

Hi Eric,

Try this:

LayerTools_2018_01.zip (2.82 KB)LayerTools_2018_01.zip (2.82 KB)

Perfect as always Marcus!

Thanks for the speedy turn around :slight_smile:


Hey Marcus!
Could you please fix LayerTools again? Same error in the 2021.


Here’s a new version for ZBrush 2021. Let me know if there are any problems.

LayerTools_2021.zip (534.4 KB)


1 Like

interesting, don’t you think you should share the source code @marcus_civis ?