ZBrushCentral

IGet operation on an ISwitch toggles it

Does somebody have issues with ISwitches (i only have one case so far) where when i IGet it in a script (or at least i think it happens because of that) it would toggle it ?
I used the script for years now in 4r7 without any of those problems. But since 4r8 it toggles it most of the time.

Anyone here who has similar problems ?

I’ve not come across anything like that. Can you post some code that shows the behaviour?

[If, [IGet, “Zplugin:MB_Xport:visible”], …] it is within a RoutineDef and is that line that i suspect to be the cause of that, nothing else in my script references that ISwitch except
for when i actually create it by that line at the bottom of the script.

[ISwitch, “Zplugin:MB_Xport:visible”, 0, “export all visibles”, , ] that line creates the ISwitch and i turn it off by default.
But if i want to activate it i have to press the switch, always twice after zbrush-startup that in it self is new in 4r8.
I got no problems at all with 4r7.

Like i wrote it does not happen always and i am not sure if it causes it but it is the only thing that i do with the ISwitch. and If it toggles off it always does so after i call the routine when a button has been presssed.

Thanks.

Yes, I meant a whole example zscript that I can test. But I think the most likely explanation is that you are simply seeing the switch reset to its default when the plugin is reloaded. In the code you have given the switch state is off when the plugin loads. It’s a quirk of ISwitches that you have to press them twice to get them to respond if the plugin isn’t already loaded. The first press loads the plugin and the second press actually presses the switch. This isn’t new to 4R8 - it’s been in ZBrush for as long as I remember. (There are ways to avoid this behaviour but I shan’t go into that here.)

For your switch turning off when you press a button, this again is when the plugin is reloaded. You can test this by using a different plugin, such as the hotkeys [ or ] to change the Draw Size, and then pressing one of your plugin’s buttons. You’ll see the switch go off because that’s its default state in your code. The easiest way to avoid this is to use a memory block to for the switch state. The code below shows how to do it. It also has a switch with no memory block so you can compare the behaviour.

[If,[MemGetSize,MySwitchMem],
[MVarDef,MySwitchMem,1,0][MVarSet,MySwitchMem,0,0]
]

[ISubPalette,“Zplugin:Marcus Tools”]

[ISwitch,“Zplugin:Marcus Tools:My Switch”
,[MVarGet,MySwitchMem,0],“Popup info Text”
,[MVarSet,MySwitchMem,0,1]
,[MVarSet,MySwitchMem,0,0]
,0.5]

[ISwitch,“Zplugin:Marcus Tools:My Switch2”
,0,“Popup info Text”
,
,
,0.5]

[IButton,“Zplugin:Marcus Tools:My Button”,“Popup info Text”
,
,
,0.5]

[IEnable,“Zplugin:Marcus Tools:My Switch”]
[IEnable,“Zplugin:Marcus Tools:My Switch2”]

Thanks a lot marcus for your explanation and all your efforts teaching zScripting to the masses.
But for some reason i can’t remember the script behaving like that pre 4r8.
Could have sworn it started with using 4r8.
Anyway Thanks a ton.
And have a good day :slight_smile: