ZBrushCentral

Questions about [SubToolGetStatus]

Hi!
So I took a look into [SubToolGetStatus] especially in combinations with folders and I am a bit confused. What I learned sofar is that the topmost Subtool in a folder holds the status of the folder (just like with boolean groups). This is great news, as I first was concerned the possibility to hide folder in the prefs, would create a nightmare to track.
Other Subtools in a folder don’t seem to have a special “is part of folder” flag though and this is where my confusion starts.
A Subtool that is part of a groups and gets hidden by the parent folder remains it’s status (e.g 17) although being not visible. I assume this was done to be able to restore the correct visibility of the content of the folder.
It makes [SubToolGetStatus] an unreliable source though, when looking through the complete Subtool list. I now have a list where a status of 17 can mean a Subtool outside a folder is visible, yet also be invisible to the user (although technically visible) inside of a hidden folder.
This in combination with the fact, that the status holds not information about Polypaint, feels like unused potential.
The status is easy to use (no name check->few lines), so it could be a slick all purpose solution. From what I have learned so far, it seems to make things more complicated though, as I now might need to check for the modifier and the status as well, to get the complete state of a Subtool.

Should I be mistaken and I simply need to wait a little longer for the documentation that will shed light on all my questions, please let me know :)!

I did a bit more digging and with the help of F@celessm!ndz on discord, we managed to come up with a solution that allows to track a Subtool’s visibility state using [SubtoolGetFolderIndex]. Which means I can now can start working with the new features :).

For the curious:

[IButton, “Subtool visible?”, ,
[VarSet,STStatus,[SubtoolGetStatus]]
[VarSet,STFolderIndex,[SubtoolGetFolderIndex]]

[If,(STFolderIndex > -1), //part of a folder
[If,(STStatus&2), //head of the folder
[If,(STStatus&1),
[Note,“Visible head of folder”]
,
[Note,“Invisible head of folder”] ]
,
[If,(STStatus&1), //member of the folder
[Note,“Visible in a folder”]
,
[Note,“Invisible in a folder”] ] ] ] [If,(STFolderIndex == -1), //not part of a folder
[If,(STStatus&1),
[Note,“Visible”]
,
[Note,“Invisible”]
]]]

1 Like

Yeah, here’s my version:

[COLOR=#e3f149][[COLOR=#ed7033]RoutineDef, SubToolIsVisible,
[[COLOR=#ed7033]VarSet, [COLOR=#f8f8f8]isVisible, 0]
[[COLOR=#ed7033]VarSet,[COLOR=#f8f8f8]actIndex,[[COLOR=#ed7033]SubToolGetActiveIndex]]
[[COLOR=#ed7033]VarSet,[COLOR=#f8f8f8]st,[[COLOR=#ed7033]subtoolgetstatus,[COLOR=#f8f8f8]actIndex]]
[[COLOR=#ed7033]VarSet,[COLOR=#f8f8f8]fInd,[[COLOR=#ed7033]subtoolgetfolderindex,[COLOR=#f8f8f8]actIndex]]
[[COLOR=#ed7033]If,([COLOR=#f8f8f8]fInd > -1),[COLOR=#8c8c8c]//it’s in a folder
[[COLOR=#ed7033]VarSet,[COLOR=#f8f8f8]stFld,[[COLOR=#ed7033]subtoolgetstatus,[COLOR=#f8f8f8]fInd]][COLOR=#8c8c8c]//get folder visibility
[[COLOR=#ed7033]If,([[COLOR=#ed7033]Val,[COLOR=#f8f8f8]stFld]&0x2 == 0x2)&&([[COLOR=#ed7033]Val,[COLOR=#f8f8f8]st]&0x1 == 0x1),
[[COLOR=#ed7033]VarSet,[COLOR=#f8f8f8]isVisible,1]
]
, [COLOR=#8c8c8c]//else no folder
[[COLOR=#ed7033]If,([[COLOR=#ed7033]Val,[COLOR=#f8f8f8]st]&0x1 == 0x1),
[[COLOR=#ed7033]VarSet,[COLOR=#f8f8f8]isVisible,1]
]
]
, [COLOR=#f8f8f8]isVisible]

The above code could easily be adjusted to take an index instead of the subtool needing to be selected. (A big advantage with SubToolGetStatus over previous methods.)

1 Like

Can you explain to me what a test condition in an IF statement means? I am a novice so I do not understand how the idea of letters & how to put there is effect. Thank you very much!

@SonBX Hey man! Welcome to the club! Imagine an IF statement like a traffic light with two colors. If the light is red you wait, if it is green you can walk.
Translating this concept to ZScript it would read something like this:

[If, trafficlight == green,      
 walk = 1
,
 walk = 0
]

Let’s take a closer look:

[If, trafficlight == green,      

//in this line after the first comma you define what you are looking for in the script “is the traffic light green?”

 walk = 1

//here you describe what should happen if in fact the traffic light is green. In this case walk.

,
 walk = 0]

//and here you define what should happen of the traffic light is not green. In this scenario, you would not walk across the street.

What really help me when starting out was reading in the forum here and studying the ZScripting section of the documentation:
http://docs.pixologic.com/user-guide/customizing-zbrush/zscripting/

Hope this helps :)!

1 Like

I mean, in the “STStatus&2” condition, what the character “&” means. And the meaning of the IF statement in Zscript, I already understand!

& is the bitwise operator which means AND.
it compares two operands (op1 and op2) and return 1 if op2 is 1 and 0 if op2 is 0

here is an short illustration :

  11111111 11110000
& 00000000 01100011
  _________________
  00000000 01100000

Hope it helps!
Nicolas

1 Like

Thanks for the answer, but I still don’t fully understand, in the @floon code wrote:
[If,(STFolderIndex > -1), //part of a folder
[If,(STStatus&2), //head of the folder
[If,(STStatus&1),
[Note,“Visible head of folder”],
[Note,“Invisible head of folder”] ]
What does the check clause (STStatus & 2) mean, how does it return the result? Because the test condition of an IF statement must be a True or False clause?
Thank you very much!