I need help writing a script for ZBrush. The task is as follows: I want to create a button (let’s call it MP) that, when pressed, checks which MatCap is currently assigned. If it is not MatCap Red Wax, the script should apply MatCap Red Wax and deactivate polypainting on all subtools. If the script detects that MatCap Red Wax is already selected, it should switch to another MatCap - MatCap White01, and activate polypainting on all subtools.
This is what I have so far, everything almost works, but only within the selected subtool, I would like it to do this with all that are in the project
// ZBrush Script to toggle between MatCap Red Wax and MatCap White01
// and toggle polypainting on all subtools
[IButton, "MB", "Toggle MatCap and Polypaint",
// Store the current material
[VarSet, currentMat, [IGetTitle, Material:ItemInfo]]
// Check if the current material is MatCap Red Wax
[If, [StrFind, "MatCap Red Wax", currentMat] >= 0,
// If it is MatCap Red Wax, switch to MatCap White01
[IPress, Material:MatCap White01]
// Activate polypainting on all subtools
[Loop, [SubToolGetCount],
[VarSet, subToolIndex, [SubToolGetActiveIndex]]
[SubToolSelect, subToolIndex]
[IPress, Tool:Polypaint:Colorize]
]
,
// If it is not MatCap Red Wax, switch to MatCap Red Wax
[IPress, Material:MatCap Red Wax]
// Deactivate polypainting on all subtools
[Loop, [SubToolGetCount],
[VarSet, subToolIndex, [SubToolGetActiveIndex]]
[SubToolSelect, subToolIndex]
[IUnPress, Tool:Polypaint:Colorize]
]
]
]