Most people start making macros by recording actions in Zbrush (ZB) and then spitting out a macro to the startup/macros folder. Let's try this:
1. I dock the Macro menu to one of the side tabs and press "New Macro"
This option will appear - I haven't ever needed to initialize so far I always click NO before I start recording. There's reasons you may want to initialize I can cover later but for simple scripts selecting NO is ok.
After which this notification will appear - you need to be careful since almost everything you are doing in zbrush is now being recorded.
2. Now you are ready to do something that you want automated:
Very simply I had 2 cylinders and then performed the following sequence in Zbrush:
Sequence 1: I pressed - Tools:Polygroups:Autogroups
Sequence 2: I then pressed - Tools:Polypaint:Polypaint From Polygroups
Sequence final: I then pressed Macro:End Macro and a save dialog appears. I saved the macro in a new sub folder and gave it the name "AGPtoPP.txt"
This folder and file is held in the ZB install with all the other macros:
"C:\Program Files\Pixologic\ZBrush 2018\ZStartup\Macros"
3. You should now have a working macro button in the macros menu:
Yay it's performing that exact sequence over and over. You can now copy this button out to a custom UI or hotkey it too.
Let's look at the script that was made:
And here's how I usually trim it immediately:
The body of the script explained:
Line 1: IButton is ZBs way of recognizing the script as a UI element, the "???" is a special tag that tells ZB the script is a macro, the "Text" is what appears in ZB as you hover above the button. Macros with this line saved in the macro folder appear as a button with the file name under the Macros Menu.
NOTE - Often when writing macros you'll break them. They'll disappear from the macros menu because Zbrush failed to compile them from the TXT file to the ZB format of .zsc
Line 2: IShowActions,0 "0" is code for "No" so this line is telling zbrush to hide the actions while the macro performs its function.
Line 3 and 4: IPress, and then the path to the UI item you want pressed. In this case it was the two pressed buttons I recorded earlier.
NOTE - Every ui in zbrush has a path. If you hold and Control and hover over a button the path will appear in the bottom of the tool tip. Match this path to the path on line 4 above to see how it's working.
Even more explanation in human speech:
So you should now know how to record, save and edit simple macros and understand a little more about how they are talking to ZB. Let me know if you record any cool ones - or have an idea of one you want made.
Next post I'll show some more advanced stuff like performing something on all your subtools and cycling through the trim tools with one hotkey.