ZBrushCentral

Tip: Determining active materials

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.

Practical explanation: In the Material palette there is a button called Show Used[color=DimGray]. When you press that button all materials that appear on the canvas are displayed in the Material palette, the rest are hidden from view. It is then a simple matter of checking if each material exists on the interface. The IExists command can take care of that.

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.

The Source Code:

[[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
As you can see above the [color=PaleGreen]IExists command does not reference the UI interface item by its interface button path, that would be tedious for 75 materials with different names. Luckily each Interface Item has a specific Window ID. The Window ID for the Material slots runs from [color=Wheat]10243 to [color=Wheat]10318. You can find the Window ID of any interface item by hovering your cursor over the interface item and examining Preferences : Utilities : View Window ID. Note, it is necessary to init the [color=SandyBrown]MaterialsUsed variable array to 0 before checking for active materials a second time.

Happy Zscripting

Mark

Cool info thanks for posting it!

Off hand do you think it’s possible to write a script that would allow you to say change the materials of the first 10 (or last 10 or whatever) slots, lets say for a particular project then save that set up etc for different projects. I know I can save the document but still have to remember what materials in what slots etc I think and if possible I would like to automate this so I could switch effortlessly from one project to the next.

If you think it’s possible I would appreciate a nudge or two in the direction of script commands I need to be looking at to do something like this.

Thanks again for the above info and also any pointers you can give me.

Great info!!!
When developing Fill routine i write a small routine to write a mask on one canvas material…
It works in this way:

  1. click on canvas
  2. the script grab the material under cursor and (with radial search method) paint a mask (white, flat color) on another layer. The mask will be painted only on connected pixols with the same material.
  3. In this way you can mask (i.e. with stencil) all the pixols with the same material.

ciao

cameyo