ZBrushCentral

Plugin Status Update Events

If I wanted to reset or modify certain plugin settings, beyond the usual IEnable, is there a way that I can run routines as a plugin’s status changes (on load, on de-activation, on activation, etc)?

Thanks!

Hi,

The Sleep command would again like to be your friend :slight_smile:

If you recall, we supplied the Sleep command an awake event of 1024 which is an interface item is pressed or depressed. But there are also event codes for startup and shutdown (your zscript became the focus and your zscript lost focus). Even better, we can combine the event codes… well we have to as you can only have 1 Sleep command per zscript as far as I know.

The startup event code is 256, the shutdown event code is 512 and, as mentioned before, the interface item pressed event code is 1024. Notice a pattern? We can either add all the event codes we want to monitor or, to keep our sanity when reviewing the code in 2 weeks time, use the bitwise OR operator ( | ). Using the bitwise operator the code would look like this.

StatupShutdown.jpg

I would probably remove the startup code as zscript / zplugins are parsed each time they become the focus. Your code outside of IButton’s, ISlider’s, ISwitch’es and Sleep commands should take care of the initialisation of data and interface items, IMO. The shutdown code would be useful to change the enabled status of your interface items.

In order to check if this is the first time the zscript is run during any given ZBrush session you would check if a memory block existed, if not, do your initialisation and then create the memory block you tested against. Memory blocks, unlike zscript variables, exist during the entire ZBrush session or until they are deleted.

Hope that is useful.

Ah! I should have seen that! I’m beginning to see a pattern here! :smiley:

Thanks again Mark, tons of good information in your reply. Thank you.

I agree with your statement about the initialization of the plugin and startup code; The shutdown code is exactly what I needed. The memory block for first time plugin load is a great idea.