ZBrushCentral

toggleable macros, how to?

Okay seeing that i like to have as much canvas real estate as possible i’ve made macros of most buttons or brushs that i need and resized them accordingly.

I would like to know how to make a macro that would function like the Double Sided button, or the huge Enable Customize, View Mask, LazyMouse.
I’m sure eventually i’ll come up with a macro that would toggle certain actions, like between two brush curves or settings, so this would be helpful.

Also if this is possible, will it show up highlighted? Speaking of which, i’ve made macro’s of the brushes but without them highlighting its easy to get confused as to which brush i have selected, or at least how to assign the push button color to them so they look different.

To make a button toggle between two actions you simply need to include an If command in your button. This checks a condition to see if it is true, then carries out one set of commands if it is true, and another set of commands if it is false.

[If,/*test for true or false*/ ,
 /*commands if true*/
, 
 /*commands if false*/
] /*end of If command*/

The condition can be pretty much whatever you want. To find the state of a ZBrush interface item, you can use the [IGet command with the button path. (To find the button path for any item on the interface, place the cursor over the item and hold down Ctrl on the keyboard. A descriptive note will appear and the button path is given at the bottom of the descriptive note.)

But for something like your curve toggle suggestion you would need to use a slightly different approach, as there would be no way of testing which curve was already loaded. The simplest way would be to create a memory block when one curve was loaded, and delete it when loading the other:

[If,[MemGetSize,SB_CurveTest]/*test for memory - a size of 0 means it doesn't exist*/ ,
[MemDelete,SB_CurveTest]/*deletes memory block*/
 /*commands to load Curve B*/
, 
[MemCreate,SB_CurveTest,1]/*creates memory block*/
 /*commands to load Curve A*/
] /*end of If command*/

(The point of using a memory block is that it is persistent throughout a ZBrush session, so your macro button will always find it. ZScript variables only last as long as the zscript/macro is active, so would be no good for a test of this sort.)

On highlighting macro buttons: I don’t think there is a way. The problem is that you can’t dynamically assign colors or images to buttons on the ZBrush interface - they simply won’t update. (Macros are also incredibly touchy and will cause problems with any adventurous code!) There is also a problem with zplugin switches (which do change color) in that currently only the off commands work. You could use a switch as a sort of indicator, switching it on or off with your button but that’s not much of a solution if you are trying to cut down on interface clutter. There may be another way; if I think of something I’ll let you know.

Sorry for resurecting this topic, but I tried to get a toggle macro and can’t get it.
My lack of scripting skill prevent me to do it.
Can you help me a little?

I tried to do the If command with Preferences:Draw:PFill

But I’m doing something wrong,I am not using the IGet command correctly I thought it could get the value of your slider.

Here is my little code:

[If,[IGet,Preferences:Draw:PFill]=25 ,
[ISet,Preferences:Draw:PFill,0]
,
[ISet,Preferences:Draw:PFill,25]
]
But I can’t get it to work.

I successfully made a toggle for the lazymouse to change the value to their default if they were changed before, but with this I can’t get it to work.

I can’t see anything wrong with your code and I just tested it in a macro without problems.

How is it not working? Do you have a macro button that you are pressing (with no result), or has the button failed to appear?

I already read something about a bug without the naming of the macro, but even if I named my macro with more than 8 char it doesn’t work.

when I hit Reload all macro I got a pop up with “improper definition of a commands-execution list”

Here is my full macro:

//ZBRUSH MACRO - Recorded in ZBrush version 3.1
[IButton,???,"Press to run this macro. Macros can be aborted by pressing the ‘esc’ key.",
[IShowActions,0]
[IConfig,3.1]
[If,[IGet,Preferences:Draw:PFill]=25 ,
[ISet,Preferences:Draw:PFill,0]
, 
[ISet,Preferences:Draw:PFill,25]
]

I named it ToggleWire and it is in Misc_macro folder.

I thought it was because it is a slider and not a switch.

Edit: Wow, even worse if I got this macro in my folder and I tried to restart Zbrush it doesn’t want to lauch the welcome screen, I have to hit Escape to go to the Defaultscipt.

Ah, if that’s your code exactly as you have it you are missing a square bracket at the end (to close the button). Try the attached version.

Haha :smiley: Thank you, that was so simple.

i finally got a handle on these and made a few, but i’m confused as to why this isnt working, zoom actual/aa half toggle.

[IButton,???,“Press to run this macro. Macros can be aborted by pressing the ‘esc’ key.”,
[IShowActions,0]
[IConfig,3.1]

[If,[IGet,Zoom:Actual]1 ,
[ISet,Zoom:AA Half,1]
,
[ISet,Zoom:Actual,1]

]
]

maybe the = sign?

[IButton,???,“Press to run this macro. Macros can be aborted by pressing the ‘esc’ key.”,
[IShowActions,0]
[IConfig,3.1]

[If,[IGet,Zoom:Actual]=1 ,
[ISet,Zoom:AA Half,1]
,
[ISet,Zoom:Actual,1]

]
]

Actually, that won’t work either as the Zoom:Actual button always returns 0. A good way to check this sort of thing is to include a note while writing a script, like I have done here:

[IButton,???,"Press to run this macro. Macros can be aborted by pressing the ‘esc’ key.",
[IShowActions,0]
[IConfig,3.1]
[Note,[CanvasZoomGet]]
[If,[CanvasZoomGet] > 0.5,
[ISet,Zoom:AA Half,1]
,
[ISet,Zoom:Actual,1]
]
]

thanks marcus, i had figured it was something like that, also that note get idea is great and will help me much.

Hi,

I’m trying to figure out what all this thread means, but I’m not experienced in coding or scripting, and it’s been 12 years since this thread opened so hopefully you can help me?

I’m trying to achieve the same thing but for toggleable buttons like dynamesh.

I’m also trying to set a toggleable macro that switches between two values on a slider. In particular, a button that, when off, has mask by polygroups as 0, and when on, at 100. Is this possible?

Thanks!