Working out what materials are used on a canvas can be useful for many things. For example, Quick saving all active materials. That would be useful for storing multiple material settings for a single document instead of saving multiple versions of a 40GB print sized Zbrush document.
Of course there has to be an exception: Whether or not the currently selected material exists on the canvas it is kept in view when Show Used is pressed. So it is neccesary to select the Flat Color material before pressing Show Used. The Flat Color material cannot be replaced or modified so it will exist in all Zbrush documents, and as such it does not need to be saved.
In Zbrush 2 there are 76 materials slots. There can be neither more nor less than 76 slots.
[[color=PaleGreen]Vardef, MaterialsUsed(75), 0 ] // If material is active 1, otherwise 0.
[Ifreeze, // Hides the following commands from the user. [Iset, Material:Item Info, 0 ] // Select the Flat Color material [Ipress, Material:Show Used] // Hides all unused materials from the UI. [Loop, 75 , // There are 76 materials but we are not interested in material 0, the Flat Color material. [If, [IExists, [Val,10244 + i ] ], // If material is visible in the UI then... [Varset, MaterialsUsed([color=Blue] i ), 1 ] // ...set to 1 for used materials ] // End of If statement , i ] // End of loop ] // End of Ifreeze
Happy Zscripting