ZBrushCentral

Trying to replicate some buttons from the default menus

HEllo there, Sorry the title is not really explicite
So, i am entering slowly into studies and reasearchs for authoring Zbrush Plugin, the objective is about to improve my tools pipeline, but i just reached a limit and i have no idea how i could fix this issue.

let me explain you all this :
It a plugin to deal with exportation , but i wanna replicate some ui buttons available into Tool:Export mainly in this specific case.
I choose to start to work with obj format right now, and this is the reason why i need to access the export settings in Tool:Export:.
I used Two Switchs and it works seamlessly within the plugin panel in direction of tool:export,
But I am aware that if any people try to edit the export setting from the original place in Zbrush Ui ( tool:export),
The new statement on my plugin is not reflected.

I know that the Second argument of the Iswitch function, define if the button is enable(1) or disable(0).
so i want this argument to be dynamic and listen/tick if the original switch button has been changed.

Let me show you the part of the script :

[ISwitch, “Zplugin:RedTools:GoZ Maya:T”,
//check what is the current state of tool:export:tri, the value to return must to be 0 or 1,
//it must to check the default value when the plugin start at zbrush startup, but it must to update if we click on the original button from Ztool : export
[IGet, Tool:Export:Tri] // <— this function should be dynamic if i clicked on Tool:Export:Tri
, “export triangulized model”, //button tooltip
//enable button
[If, [IGet, Tool:Export:Tri] !=1, // if triangle is not enable,
[ISet, Tool:Export:Tri, 1]
[ISet, “Zplugin:RedTools:GoZ Maya:Q”, 0 ]
,//else
[ISet, Tool:Export:Qud, 0]
]
,//endif
//disable button
[ISet, Tool:Export:Qud, 1 ]
[ISet, “Zplugin:RedTools:GoZ Maya:Q”, 1 ]
]

[ISwitch, “Zplugin:RedTools:GoZ Maya:Q”,
//check what is the current state of tool:export:qud
[IGet, Tool:Export:Qud]
, "export quad model ", //button tooltip
//enable button
[If, [IGet, Tool:Export:Qud] !=1, //If Quad is not enable
[ISet, Tool:Export:Qud, 1]
[ISet, “Zplugin:RedTools:GoZ Maya:T”, 0]
,//else
[ISet, Tool:Export:Qud, 1]
]//endif
,
//disable button
[ISet, Tool:Export:Tri, 1 ]
[ISet, “Zplugin:RedTools:GoZ Maya:T”, 1 ]
]

Here it works but only read the state of tool:export:tri at the startup.

I tried that , but it may return a bad value and the plugin won’t rebuild[ISwitch, “Zplugin:RedTools:GoZ Maya:Q”,
//check what is the current state of tool:export:qud
// [IGet, Tool:Export:Qud] //disable
[If, [IPressed, Tool:Export:Qud],
[ISet, Tool:Export:Qud, 1]
,//else
[IGet, Tool:Export:Qud]
]
, "export quad model ", //button tooltip
//enable button
[If, [IGet, Tool:Export:Qud] !=1, //If Quad is not enable
[ISet, Tool:Export:Qud, 1]
[ISet, “Zplugin:RedTools:GoZ Maya:T”, 0]
,//else
[ISet, Tool:Export:Qud, 1]
]//endif
,
//disable button
[ISet, Tool:Export:Tri, 1 ]
[ISet, “Zplugin:RedTools:GoZ Maya:T”, 1 ]
]

Sorry but look like there is no code tag on the forum, and coloring text is not featured too , so i used big font to show you what is wrong.

Any kind of help would be greatly appreciated :slight_smile:

Nicolas

This may be useful to you in the future>> http://www.zbrushcentral.com/misc.php?do=bbcode
I have some custom scripts. But can’t help you much beyond offering them to you at the link below.

thank you for trying to help Doug its greatly appreciated :wink:
i just have replace the wrong makeup so it looks better right now, thx for the link.

Well,Hell from what i understand it not possible to have that to be dynamic, i could use all the available functions like loop and delay, if i can’t tick to refresh the status from the Ibutton, it can’t to work.
the good, is that my code in the plugin set the export:tri and qud to the correct value that match the plugin settings with just one click on T or Q button.
but i am not out of any problem considering that some people could use the original menu , but i am sure if they use my plugin to export they would notify that not proper settings. this is something it seems impossible for me to resolve

Anyway i took a look at your Alternative UI, i didn’t found anything that resolve my issue, but neat work, will maybe give a try someday :slight_smile:
Nicolas

Hi,

There are some important rules and limitations you should be aware of when zscripting. If you already know them then pardon the repetition.

Lifetime of a ZScript or ZPlugin:

ZBrush only has one zscript or zplugin running at any given time. So while ZBrush loads and parses your .zsc file at startup, it quickly continues to the next .zsc file. At that point your zplugin is no longer active and does not respond to changes made to the UI settings in ZBrush. This is a pretty common behaviour of programs that include scriptability or plugins.

Unfortunately there are no callbacks in zscripting. So if you would like to detect the settings of the Tool : Export subpalette you would probably want to create an Export Settings button which would reveal your export switches and set them to the correct values. The actual export button would then hide the settings again. The only problem is that the user could decide to switch to another tool and the export settings for the previous tool would still be showing.

Program Flow of a ZScript or ZPlugin:

When ZBrush is launched it loads all the .zsc files in the /ZStartup/ZPlugs directory, but it does not execute every zscript command in those files. Examine the following code and guess which message is shown:

programflow.jpg

Yes, I to am sitting with ZBrush on a Saturday night :lol: Every IButton, ISlider and ISwitch is evaluated when you load the .zsc file but the zscript commands they contain are not executed until someone interacts with the interface item they generate. If you activate another zscript or zplugin, the focus shifts and your code stops executing.

If you return to your zscript or zplugin you will find that you are once again sitting with ZBrush on a Saturday night. In other words every command outside IButton, ISlider and ISwitch is executed each time your zscript or zplugin becomes active.

Solution ?

Instead of placing the export options in the ZBrush interface you could have a single button, your export button, which launches a note window with the various export options. Because the user pressed your export button, your zplugin becomes active and can query the current export settings before showing the note window.

Hope that helps a little.

Hey Thank you a lot TVeyes for full review about of the internal Zbrush process concerning the .zsc files, it make sense, and it was what i expected sadly.
Thx for bringing me sad new :slight_smile:
But yea anyway i think your methodology to bypass a note windows could work, excepted that i really want to prevent from bothering people with such of feedback,
I want it to be fast with the minimum of click to interact and sent stuff from Zb to Maya and back.
but I still open and will list the pro and cons of the note window. if I get several case that create confusion and could append any conflict or bug, i would opt for your method.

I think i will have some more questions, and will probably post again on that topic all along the development of the toolSet I’d just started.

My objective is about to create a plugin for Zbrush to exchange with most of the tools I use for game development (Zbrush, MayaLT, Substance batchtool and UE4)
I already have done an Editor plugin for UE4, but it’s just a copy of an existant tab from the placement tool but it just necessary to fill the new tab with cool
functions, like exporting grouped static meshes or Bsp Brushes from UE4 then have them imported in ZB/Maya.
Well I think this will be a long development and i could be very slow at that , because i also have some game asset to create :slight_smile:

I finally have a new set of questions :slight_smile:

Is it the way to create an array variable ?
Is the parenthesis are limited in use only for Array variables and for math functions ?
exmaple :
[Vardef, myObject(myComponent), “”]
[Vardef, myComponent, 0)

I will have to see how to increment a value, using VarInc or VarDec, but it seems you can increment like that :

[VarSet, myObject(myComponent+1)]

sorry i still not very familiar with this syntax, because of the manner the vars are defined,
it’s not easy to clarify what is a bool what is an integer, but i guess that Zbrush automatically understand if it a bool a float or an integer,
just that it s not that clear at first times.

You nearly got it, in this case you need to define the size of the array before you define it:

[VarSet, components, 6]
[VarDef, list(components), " "]

[Loop, components,
[VarSet, list(index), [StrMerge, "Item ", index+1]]
[Note, list(index)]
, index]

If the array is a fixed size you can be explicit:

[VarDef, list(12), " "]

Incrementing / decrementing a value can be done a couple of ways:

[VarSet, aNumber, 6] // You need to have aNumber defined before you can do the following.
[VarSet, aNumber, aNumber - 2] // 4
[VarInc, aNumber] // 7
[VarSet, aNumber, [Val, aNumber - 2]] // 4
[VarSet, list(aNumber - 1), “Hi”] // The sixth item in list is set to “Hi”, aNumber is still 6. Arrays are 0 based.

I only use [VarDef,…] for arrays, for simple variables I use [VarSet,…] which both defines and sets the variable to a value. Variables created with [VarDef,…] and [VarSet,…] are either string or float values. To check for boolean conditions simply check against the value. If it is 0 then it is false, if 1 (or higher) it is true.

Hi Mark thank you a lot again, this is more than i hoped
sorry for the late reply i had been very busy this week :wink:

No worries :slight_smile:

You should also be aware of variable scope in zscripting. A variable defined inside an [IButton,…] only exists while the commands inside the [IButton,…] are being executed. Once the button is done, the variable is gone. Also remember that activating another zscript will wipe all your variables.

The solution is simply to define global or top level variables for allowing one button in your script to set a value and another button in your script to read it. Memory blocks allow variable persistence between the loading of different zscripts and also inter zscript communication.