NOTE: In 3ds Max there is a global variable called “sceneMaterials” that contains all the current scene materials. However since at least Max 2009 there is a bug that causes the sceneMaterials variable to not properly update when, for example, scripts add/remove materials. This can (and most likely will at some point) cause incorrect results when using scripts that deal with adding/removing/listing materials.
If you find incorrect results (such as a material that should no longer exist) there is an easy solution. In order to properly update the sceneMaterials variable simply apply a new material using the material editor. Here is the process I like to use: Take a piece of geometry in your scene and sample its material into one of the editor slots. Now apply an unused material to the geometry (like one of the default materials) and then apply its original material. The sceneMaterials variable will now be updated, all you have to do is press the update button on the rollout to refresh its list.
Constant/Randomize (radiobutton): Constant will use the min value for the modifier ID. Randomize will assign a random value to the modifier ID between (but including) the min and max.
Min: The minimum ID value. Will be the value used when constant is selected.
max: The maximum ID value.
Selection Only: Operate on only the selected objects. When disabled will operate on all scene objects.
Collapse Stack: Collapses the stack after assigning the modifier.
Assign Material Modifier(s): Executes the script and assigns the material modifier.
Total: The total number of materials found.
Update: Updates the material list.
Material List (multilistbox): The list of materials found.
Assign Material ID: Assigns the material ID to the selected materials in the list.
ID Value (spinner): The ID value.
Assign Sub Material IDs: Assigns ascending ID values to all sub materials of all selected materials (i.e. A material with 10 sub materials would get: subMaterial#1ID = 1, subMaterial#2ID = 2, etc)
Reset All Material IDs: Sets ALL material IDs to 0.