How To > Remove All Materials |
This is one of the shortest scripts one could imagine, and yet very powerful and useful. It will let the user remove all materials from the scene objects.
NATURAL LANGUAGE |
Package the code as macroScript to be used as button, menu or shortcut. |
Set the material property of all objects to undefined to remove any material assignments. |
The macroScript will be called NoMaterials.
To use the script, you can go to Customize... and drag the script from the category "HowTo" to a toolbar, a menu, a quad menu or assign to a keyboard shortcut.
A good place to put it into would be the new menu of the Material Editor in 3ds Max 5.
MAXScript will iterate through all scene objects because $* is a wildcard for any object name found in the scene.
The material object property assignment is mappable, which means that MAXScript will take the collection of objects on the left side of the assignment operator "=", loop internally through all objects in the collection and assign the right-hand expression (in this case the value undefined) to them.
When an object is first created, its .material property is by default set to undefined.
When a material is assigned to an object, the .material property would return the Material object.
Setting the material property to undefined will effectively remove the assignment of the material to the object and thus restore the object’s default state.
To use it, you can use Customize... to drag the script from the category "HowTo" to a toolbar, a menu, a quad menu or to assign to a keyboard shortcut.
In 3ds Max 5 and higher, you could customize the Material Editor’s menu to place the new Item for cleaning the scene materials there!
This operation is very destructive – you might want to add a Yes/No query to make sure your user knows what he is doing. Take a look at