ZBrushCentral

How to zscript "alt" button press for an alternate script to run on a single IButton?

Basically I want to be able to script two commands running off of the same button.

Like how the ZRemesher can run two different zremesh algorithms off of the ZRemsher button depending on if the user holds down “alt” or not when it’s pressed.

Is this possible? Or something that is hard coded into the ZRemesher button in Zbrush? I couldn’t find anything online or in the command reference.

Thanks,

E

Hi Eric,

Try this code:

[VarDef,keyOnMouseDown,[IGet,preferences:utilities:viewkeyboardstatus]]

[Sleep,0.001,
[If,SleepResult==4,//waits for keypress
[VarSet,keyOnMouseDown, [IGet,preferences:utilities:viewkeyboardstatus] ]
]
[SleepAgain],4,sleepResult
]

[IButton,“Press Me”,“Hold Alt for alternative result”,
[If,((keyOnMouseDown)&1024)==1024,
[Note,“You pressed the Alt key”]//commands for Alt keypress on click button
,//else
[Note,“You didn’t press the Alt key”]//commands for straight mousedown on button
]//end if
]

G damnit Marcus you brilliant bastard!

Love you so much!

THANK YOU!!!

Hi,

I just discovered that pressing Alt when pressing the ZRemesher button in a custom UI toggles the Tool column at the right side, instead of activating the alternative ZRemesher algorithm.

Maybe this is a macOS-only issue, but I’m looking for a workaround, because I really like the ZRemesher button in my custom UI. Could the above-mentioned script be the solution? If so, how should I turn it into a custom UI button that loads every time I start ZBrush?

Many thanks in advance for your help.

Hi,

You have to have a new button on your UI, but this will work. It’s a macro which presses the ZRemesher button while holding Alt. Save to ZBrushOSX 2018/ZStartup/Macros/Misc folder and press Macro>Reload All Macros. There should then be a new button in the Macro palette called “ALT-ZRemesh”. You can move the button to your custom UI.

ALT-ZRemesh.txt (263 Bytes)ALT-ZRemesh.txt (263 Bytes)

Many thanks, Marcus, much appreciated! :+1:

Hi! I suggest you could use CTRL instead of ALT to trigger secondary command because it is easier to catch. YOu could try this codes.
[IButton, TestButton, “”,
[VarSet, CTRLisPressed, 0]
[VarSet, slBrushInfo, [IgetInfo, “Brush:Current Brush”]]
[VarSet, slFind, [StrFind,“Base Type: Mask”, #slBrushInfo]]
[If, #slFind > -1 ,
[VarSet, CTRLisPressed, 1]
,]

[If, #CTRLisPressed , // CTRL is pressed. [NOte, "CTRL is pressed down"] // SAMPLE CODE // PUT THE CODES HERE ,// CTRL is not pressed. [NOte, "CTRL is not pressed down"] // SAMPLE CODE // PUT THE CODES HERE ]

]

Hi! I suggest you could use CTRL instead of ALT to trigger secondary command because it is easier to catch. YOu could try this codes.
[IButton, TestButton, “”,
[VarSet, CTRLisPressed, 0]
[VarSet, slBrushInfo, [IgetInfo, “Brush:Current Brush”]]
[VarSet, slFind, [StrFind,“Base Type: Mask”, #slBrushInfo]]
[If, #slFind > -1 ,
[VarSet, CTRLisPressed, 1]
,]

[If, #CTRLisPressed , // CTRL is pressed. [NOte, "CTRL is pressed down"] // SAMPLE CODE // PUT THE CODES HERE ,// CTRL is not pressed. [NOte, "CTRL is not pressed down"] // SAMPLE CODE // PUT THE CODES HERE ]

]