ZBrushCentral

Callback on Brush Selection

Does anyone know if there any way that I can run a bit of code, when a brush is changed? I would basically want to check some common brush settings, and possibly change them when the brush is changed (essentially creating a global brush setting override when this plugin mode is enabled).

Thanks!

Hi,

There is no global callback feature for what you are thinking of, but there is a zscript command called Sleep which might work for you, if you can accept the general zscripting limitations. As you probably know, only one zplugin can be active at any given time. So as soon as the user presses the Projection Master button, for example, your brush settings zplugin is deactivated and will need to be reactivated by the user.

If you can live with that limitation you can set the Sleep command to awaken itself whenever the user presses an interface item. At that point you get a chance to run your zscript commands to test if a new brush was selected. The following will detect if the name of the currently selected brush differs from the previously registered brush name and notifies you in the notebar:

BrushMonitor.jpg

I should note that this zscript only checks for normal brush changes, to check for masking and clipping brushes you would probably need to simulate a modifier key press (CTRL for masking, CTRL + SHIFT for clipping) with IKeyPress and register the brush name. Hope that gets you started.

Wow, that will definitely do; Thank you very much TVeyes! I figured there wasn’t a typical callback method, but this seems like a fine alternative for what I need it to do.

Yes, the fact that [Sleep] will exit if a different plugin is called is the big drawback with this method but it’s the only option using zscript.

Also, sadly ZBrush won’t allow

[VarSet,interfacePath,[IKeyPress,CTRL,[IGetTitle,30501,1]]]

so the method can’t be used for Masking/Selection brushes. I can’t think offhand of a way of getting those.

Yeah, that is a bit disappointing but there might be another way.

Just focussing on the smooth brushes lets say we can determine all their brush names, most likely by manually creating a list. We can then use the IGet command which will return 1 if a given smooth brush is selected and 0 if it is not. The following seems to work.

[IKeyPress, SHIFT, [VarSet, isSmoothBrushSelected, [IGet, “Brush:SmoothPeaks”]]]
[NoteBar, isSmoothBrushSelected]

The only problem would be detecting smooth brushes other than the default ZBrush ones. Perhaps searching the ZStartup/BrushPresets folder for brush files?

Btw Marcus, I think you should have the VarSet within the IkeyPress command although it does not seem to work either way.

Mark,

Yes, of course, it should be that way around.

Thanks,