ZBrushCentral

Booleans Ops? Concatenating a number with a string?

Here’s a routine I’m writing to find the currently active layer, based on TVEyes’ older article:

[RoutineDef, GetActiveLayer,
[Loop, 16,
[VarSet, layer, [StrMerge, "Layer:Layer ", n+1]]
[VarSet, flags, [IGetFlags, layer]]
[If, (flags=10) || (flags=11),
[VarSet, result, layer]
[LoopExit]
]
, n]
, result]

I haven’t yet tried to run it; for one thing, I need to know the boolean or operator in ZScript (line 5), and can’t find it in the reference materials.

And while I’m asking questions, does anyone know if line 3 (concatenating a number to the end of a string with StrMerge) will work? If not, how should this be done.

Thanks,
Ken

Use double == signs for comparison.
if you are asking If Flags is equal to 10 or 11
[If, (flags==10) || (flags==11),…

The stringMerge should work like this. [Var,n]+1
[VarSet, layer, [StrMerge, "Layer:Layer ", [Var,n]+1]]

just having n+1 as an argument may crash ZBrush or give you the string “n+1”

Actually, the loop counter variable doesn’t return the right value when you try to add to it in a StrMerge. It’s fine left on its own but then you’ll have a value of 0 to contend with and there’s no Layer 0.

The simplest way is to do this:


[Loop, 16,
[VarSet,x,(n+1)]
[VarSet, layer, [StrMerge, "Layer:layer ",x]]

On signs, I think in If statements, (although either work fine as above) single is more dependable:


[IButton,,,
	[VarDef,p,27]
	[VarDef,y,25]
	[If,p|y>24,
		[Note,OK],[Note,NOT]
	]]
	
[IButton,,,
	[VarDef,p,27]
	[VarDef,y,25]
	[If,p||y>24,
		[Note,OK],[Note,NOT]
	]]

I use the [Val,…] command to include the loop counter in the [StrMerge,…].


 [VarSet, LayerActive, 0]
 [VarSet, LayerCount, 0]
 
 [Ibutton, "Layers Info",,
 
 [Loop, 16,
 [If, [IGetFlags, [StrMerge, "Layer:Layer ", [Val, n+1]]] > 9,//there can only be 1 layer with flag 10 or 11
 	[VarSet, LayerActive, n+1]
 ]
 [If, [IGetFlags, [StrMerge, "Layer:Layer ", [Val, n+1]]] = 0,//layer is not created
 	[VarSet, LayerCount, n]
 	[LoopExit]// no need to test more layers
 ]
 ,n]
 
 [Note, [StrMerge, "Active Layer :   ", LayerActive, "
Number of Layers : ", LayerCount]]
 ]
 
 
       
Depending on what you want to do you might also have to test for created layers that are disabled/hidden (flag 8).

You can also use the Interface Item ID numbers for Layer buttons:

[VarSet, LayerID, 3841 + counter ] // where counter would be 1 thru 16

Sven