ZBrushCentral

Cycling through SelectionTools

EDIT: Whups. Wrong Forum. Can this be moved to the Scripting Help Section. Sorry about that !

Hey,
trying to adapt Marcus’s ToggleBrush Script to cycle through all of Zbrushs ever increasing Mask Selection Modes (Lasso, Rectangle, Curve etc.) with one hotkey. The way I see it (novice …) I just need to add more cycles to the original Macro.
Now the question is why can’t I store Selection Modes with the IGet,Brush:Item Info and what do I need to use instead ?

Thanks for reading.
Jens

Ok, badly phrased - let me try again:

“Item Info” will return me the currently active Brush. However the currently “active” (even if not currently used via ctrl) Mask Mode (Item Info 43-48) will only be revealed by Zbrush once Ctrl has been pressed.

Following the “Toggle Brush” macro Sample from Marcus I want to find out the currently “active” Mask Mode and then cycle through the brush infos upwards. So if Item 46 is active (once again - only once Ctrl is pressed) it would go 47,48 and then jump back to 43.

But how do I find the currently active Mask Mode via the “Item Info” without pressing CTRL first ?

If you want to cycle through several brushes you don’t really need to store the selection, you just declare a list of the brushes and then have an index variable which is incremented each time so the next in the list is chosen.

The attached macro shows the method. You could add any number of brushes to the list if you wanted, though I’m not sure how useful that would be. :slight_smile:

There is a minor drawback: the first time you use the hotkey you’ll get a message about the brush being ‘selected as the active mask brush’. So long as you choose the ‘skip’ option this won’t show again.

Download:

Edit: I’m not sure it is possible to get the current Mask Brush selection through zscript (at least, I haven’t found a way).

HTH,

Works flawlessly. So much for my Zscript Try-Out :slight_smile:
You should put that in the Small & Useful ZScript Section ! Very handy.

By the way i sthere any script to switch between the last used and current brushes?

Not as such (it’s not possible to record the current brush using zscript) but there is a ‘favourite brush toggle’ which you may find useful : Useful-small-ZScripts-and-Macros : Brush Toggle

Thanks! I give it a try!

Hi there - I was trying to cobble the essence of this script to work with the Surface Dial. Essentially the script would be the same but with 2 buttons - I would like the ‘index’ variable to store what brush it’s on so it can shuffle backwards and forwards through the list.

At the moment however it seems to always default to the start of the list - most likely because I don’t know how it’s stepping through. Any help appreciated!

//variable declarations - declare the brush paths
[VarDef,index,0]
[VarDef,numBrushes,3]//the number of brushes in list (change if adding more)
[VarDef,maskBrush(numBrushes),""]//list variable
[VarSet,maskBrush(0),“Standard”]
[VarSet,maskBrush(1),“Claytubes”]
[VarSet,maskBrush(2),“MoveTopological”]

[If,[MemGetSize,MaskBrushCycle_Mem],[MVarDef,MaskBrushCycle_Mem,1][MVarSet,MaskBrushCycle_Mem,0,0]]//create memory if necessary

//
[ISubPalette,“Zplugin:BrushDial”]
[IButton,“Zplugin:BrushDial:Shift UP”,“Cycle Brushes”,
[IShowActions,0]
[IConfig,4.2]
[IPress,[StrMerge,“Brush:”,#maskBrush(index)]]//presses brush
[NoteBar,[StrMerge,"\Cff9923",#maskBrush(index),"\Cffffff selected"]]//displays brush selected in Notebar
[VarInc,index]//increment the cycle
[If,index >= numBrushes,
[VarSet,index,0]
]
[MVarSet,MaskBrushCycle_Mem,0,#index]//store value
,1]

[IButton,“Zplugin:BrushDial:Shift DOWN”,“Cycle down Brushes”,
[IShowActions,0]
[IConfig,4.2]
[IPress,[StrMerge,“Brush:”,#maskBrush(index)]]//presses brush
[NoteBar,[StrMerge,"\Cff9923",#maskBrush(index),"\Cffffff selected"]]//displays brush selected in Notebar
[VarDec,index]//increment the cycle
[If,index < 0,
[VarSet,index,2]
]
[MVarSet,MaskBrushCycle_Mem,0,#index]//store value
,1]

]

Hi,

You need to change the index value before changing the brush, so that the index value stored is the current brush, not the “next” brush. Also, the memory block isn’t being used in your code - the value is stored but never retrieved. The point of the memory block is to make sure the value of index is not lost should another plugin be used. (Ordinary variables are reset to their defaults when the plugin is reloaded.)

//variable declarations - declare the brush paths
[VarDef,index,0]
[VarDef,numBrushes,3]//the number of brushes in list (change if adding more)
[VarDef,maskBrush(numBrushes),""]//list variable
[VarSet,maskBrush(0),“Standard”]
[VarSet,maskBrush(1),“Claytubes”]
[VarSet,maskBrush(2),“MoveTopological”]

[If,[MemGetSize,MaskBrushCycle_Mem],
[VarSet,index,[MVarGet,MaskBrushCycle_Mem,0]]
,[MVarDef,MaskBrushCycle_Mem,1][MVarSet,MaskBrushCycle_Mem,0,0]
]//create memory if necessary

//
[ISubPalette,“Zplugin:BrushDial”]
[IButton,“Zplugin:BrushDial:Shift UP”,“Cycle Brushes”,
[IShowActions,0]
[IConfig,4.2]
[VarInc,index]//increment the cycle
[If,index >= numBrushes,
[VarSet,index,0]
]
[IPress,[StrMerge,“Brush:”,#maskBrush(index)]]//presses brush
[NoteBar,[StrMerge,"\Cff9923",#maskBrush(index),"\Cffffff selected"]]//displays brush selected in Notebar

[MVarSet,MaskBrushCycle_Mem,0,#index]//store value
,1]

[IButton,“Zplugin:BrushDial:Shift DOWN”,“Cycle down Brushes”,
[IShowActions,0]
[IConfig,4.2]
[VarDec,index]//increment the cycle
[If,index < 0,
[VarSet,index,2]
]
[IPress,[StrMerge,“Brush:”,#maskBrush(index)]]//presses brush
[NoteBar,[StrMerge,"\Cff9923",#maskBrush(index),"\Cffffff selected"]]//displays brush selected in Notebar

[MVarSet,MaskBrushCycle_Mem,0,#index]//store value
,1]

]

HTH,