ZBrushCentral

ZScript question - about selected Layer

This is probably simple but it’s late and I seem to be stumped.

Can anyone suggest a script command that will tell me which of the 16 layers is currently selected (not just enabled)?

If I loop and look at all 16 layers I can tell those that are currently visible or active, but I can’t figure out how I can tell which is the Layer currently being worked on (the layer with the yellow box).

What I want to do is store the currently selected layer, move to other layers to do something and reselect the originally selected layer when the routine ends.

Thanks for any help,

Sven

Hi there. Sorry it took so long, but I didn’t know the answer, either.

There is not a direct ZScript command to do this. But there is another way:

IPress the << button until it becomes disabled. Increase the count each time you do. This will tell you the layer’s number. Now IPress the >> button that same number of times to return to the active layer.

Hi Matt,

Very tricky. So. What this does is move the active layer up until it becomes layer 1, then it becomes disabled. Your counter tells you what level it started at and you simply move it back to that layer.

Everything is as it was except now you know what layer you were on when you started.

Works for me! Now I just have to try it out. Thank you very much for this!

Sven

By the way, if you put the commands for the check inside an IFreeze command, then the end user won’t see the check in progress. It’ll happen behind the scenes.

Hi Matt,

Tried your suggestion and it works as advertised. Thanks for the tip.

As for using IFreeze, I found that in the commands list and first tried it out in UVConvert. Very handy! :smiley:

Can’t wait to see what you guys cooked up for ZScripting in the new release…

Here is a little test script called LAYERSHIFT.TXT that I used the selected layer routine for. It shifts ALL the ACTIVE layers down and over by 1/4 of the canvas dimension, handy for working on tileable images. (I posted an earlier version elsewhere under the name SHIFT3.TXT)

[Edit]
As usual, this simple little puzzle is more complex than I thought. I’ll try to solve all possible combinations, then repost a revised version of LAYERSHIFT.TXT :mad: (grrrr)

[ReEdit]
Problems solved - restoring to the selected Layer when it’s not an active layer… :slight_smile:

LayerShift.txt

Sven

I cannot remember if this command first appeared in Z2 but it makes it a great deal easier to find the selected layer.

By using the [IgetFlags,UI path ] you get any flags that may be assigned to Interface items.

For layers the flags are as follows:

:white_small_square: 0: Not Created
:white_small_square: 8: Disabled
:white_small_square: 9: Enabled
:white_small_square: 10: Disabled and the active layer
:white_small_square: 11: Enabled and the active layer

So to find the active layer do a loop of 16 while testing to see if the layer has a flag of 10 or 11(it can only be one of them).

Hi TV,

I think IGetFlags is new to Z2. It WOULD make things a bit easier working with Layers and maybe some other interface items as well - THANKS for pointing this out and I’ll give it a try. :slight_smile:

Did you find the flags described somewhere or from testing?

Sven

P.S. Another ZScript question I had that you might have some idea about…

I wanted to make an IButton that transforms the model one unit when clicked but transforms 10 units when clicked while the ALT key is pressed.

I kludged together something that grabbed the value at Preferences:Utilities:View Keyboard Status, then divided it by 1024… etc., but it’s not reliable, so I chucked it.

Have you found any other ZBrush command that might consistantly read a pressed key?

Does IKeyPress apply at all or is that strictly for key press simulation?

Thanks again!

Hi Sven,

The flags were discovered during testing a new script. I lost my previous script that made heavy use of layers and I could not remember how I did it. So after initiating a search on ZBC I took a look through the Z2 Zscript commands and there it was,[Igetflags]. Long story short, the search function on ZBC takes far to long, but a good thing in this case :slight_smile:

[IkeyPress,…] is only for simulation as you said.

Have you tried doing a read on the Preferences : Utilities : View Keyboard Status immediately after the button is pressed? So if the above item = 1140 (ALT key) do something else. I have not delved much into it otherwise, sorry.

A curious thing just occured regarding the [IgetFlags,…] when used on layers. I tried to [Iset,…] all layers with the value 11. Afterwards the flags read 2 for non existing layers??! Also the active layer changed to the first disabled layer(still disabled).

I think there is more to find here, just hope it is not a bug :slight_smile:

Hi TV,

2? Interesting. I’ll knock around on the IGetFlags a bit to see what I find. :slight_smile:

As for Preferences:Utilities:Read Keyboard Status, I’ll try it again, reading right after the button press - the value, the way I understand it, is Shift = 256, Ctrl = 512, Alt = 1024… And the actual value displayed combines the code representing the last-pressed normal key with the value for Shift, Ctrl or Alt key (as long as it remains depressed). So I test for Alt being depressed by getting the INT of the read value divide by 1024. If the result is 1, then the key is being pressed.

Sven