ZBrushCentral

re-loading zscript - zscript help

Hello,

n00b zscripter at it again! I am working on a bit of script that will automatically close and reload a pre-defined zscript.txt. It saves me a ton of time when iterating on a zscript so that I don’t have to close zbrush, delete the source .zsc file, re-load zbrush and re-load the source .txt file.

I have it working for me. The only issue is that if I try to run the re-loader script from the main menu ZPlugin drop down palate when it isn’t docked to the left or right side of the zbrush interface then I get a weird UI bug where it places the palate for the script that I’m trying to re-load right on top of the main menu ZPlugin palate. If if I try to run the re-loader script from the the Zplugin palate that IS docked to the left or right side of the zbrush interface, then everything executes fine. The defined zscript is closed and re-loaded and there are no issues.

I’ve tried using this “re-load” script to reload several different zscripts and it works on all of them, but the same weird UI palate issue happens on all of them so I don’t think it’s an issue of the zscript that I’m trying to re-load. I think it’s either a weird UI quirk of zbrush itself or something with this below re-loader code.

Here is a video showing the isssue
If anyone has any insight into this, I would love to hear it :slight_smile:

Also, feel free to use the below code for your own zscripting projects if you find it helpful. I was planning on giving this away as soon as I sorted out this weird UI issue!

Thanks

Here is my code so far:

[ISubPalette,“Zplugin:E Tools Reloader”]
//creates sub palate in Zplugin palate for Reload Tools

[IButton, “Zplugin:E Tools Reloader:Reload E Tools”,
//creates button for Reload E tools

[IShowActions, 0]

[If, [IExists,Zplugin:E Tools],
//first checks to see if the above palate exists, if it does the next three commands are ran. If not the last two commands are ran.

[IClose,Zplugin:E Tools]
//command that force closes a specific Zplugin:Palate, in this case the “E Tools” palate will be closed with the above command

[FileNameSetNext,“ZBRUSH_\ZStartup\ZPlugs64\ETools. txt”]
//command to load a specific .txt file from ZStartup/Zplugs64 directory inside of zbrush

[IPress,Zscript:Load]
//command to load a zscript file

]

[FileNameSetNext,“ZBRUSH_\ZStartup\ZPlugs64\ETools. txt”]
//command to load a specific .txt file from ZStartup/Zplugs64 directory inside of zbrush

[IPress,Zscript:Load]
//command to load a zscript file

]
//end script

Hi Eric,

That’s interesting, I’ve not come across that before. I use a similar method when testing code but I invariably have the palette open. Doing it your way gave the problem you describe. I don’t know why - presumably a bug.

I found that if your “Reloader” is in a different palette then the problem doesn’t occur. For example, a subpalette in the File palette:

[ISubPalette,“File:E Reloader”]

[IButton, “File:E Reloader:Reload E Tools”,

HTH,

Thanks Marcus,

Glad I’m not the only one with the issue :slight_smile:

Cheers

Hello Eric,

I use a similar method to reload my WIP zscripts but only just noticed the problem you described; I always test with the zplugin palette docked. I can live with the limitation as [IClose,…]'ing a subpalette and reloading should only be used while testing, not in anything we release.

Looking at your code it seems you are reloading the zscript twice if the subpalette exists. This will cause you to run out of interface IDs sooner rather than later. When a zscript is loaded each zscript generated interface item is assigned an interface ID and when you [IClose,…] the ID is not reclaimed. The IDs are assigned by a simple increment and are finite. Once you run out of IDs ZBrush becomes sluggish and unstable.

I know you are aware of this but it is important enough to repeat: Never release ZPlugins that [IClose,…] a subpalette in order to reload itself. If you need to update interface items there are other, much better, solutions.

Here is the code I normally use to reload, which is very similar to yours:

[IButton, “ZPlugin:Reload Command Test”, “Reloads the test.txt zscript”,[If, [IExists, “Zplugin:Command Test”],

[IClose, “Zplugin:Command Test”]

]
[FileNameSetNext, “test.txt”]
[IPress, “ZScript:load”]
, 0, 1, , , 0.5]

Thanks Mark,

You are right I definitely don’t need to re-load it twice, good catch! I had heard about the ID thing before, but have never ran into an issue with it (yet) ;).

And yes I was not going to release the [IClose…] code in anything. Thank you for the reminder though. I was only referring to posting the source for the re-loader code for any other zscripters out there that may find it useful for iterating on their own scripts as I’ve never seen anything like it on the forums before and I find it EXTREMELY useful.

Thanks for posting your re-loader source as well. Much appreciated!

Mark,
Thanks for catching the duplicate code!

Eric,

I agree, it is extremely useful. So much so that I doubt I could make myself write another ZScript if easy reloads was not a possibility.

Sorry if I came across as trying to lecture anyone. Definitely not my intent. I just find it important we emphasise that this technique is only for testing ZScripts lest Pixologic remove the IClose command altogether. To be fair, I have only run into the ‘reload overload’ a couple of times, but I would imagine we all would encounter it at some point if we started using the technique in released ZPlugins.

Mark,

I know you caught it, you were just waiting to see if I still read the forums:)

No need to apologize, I appreciate the information. You both are such a huge part of the scripting knowledge on this forum any info you guys want to give is always welcomed.

Thanks again for taking the time :slight_smile: