How to delete materials in blender
How to delete materials in blender
I’m testing different materials in the same object, and finally the file has a lot of unnecessary material, is there any command that performs the cleaning of these materials automatically? in short, is it possible to make them disappear from the file?
9 Answers 9
How about the well hidden deathray button?
Go to the outliner, choose «Orphan Data» instead of «All Scenes» and hit «Purge All».
Unused Materials will disappear as soon as you save and re-open the file. These are listed with a 0 next to their name.
To make a material lose all its users (hence have 0 users and be removed the next time you open that file), press Shift and left click on the X icon next to the materials’ name on Material Properties.
running this code will do it 🙂
Just to clarify what this code does:
This line iterates over all data blocks in the «materials» data set. Blender has data sets like these for various types of objects;
It’s worth exploring these as they are Blender’s way of exposing the data you’re looking for in an easy-to-get-to data structure.
This line basically asks whether the «users» array in the «material» data block is not valid, aka, whether it’s empty. If it is, this statement will return True; in other words this material is not being used by any other data blocks and is thus not fulfilling any purpose in the file other than take up space. This would be the same condition as would be fulfilled if you «clear users» and then save and re-open a file.
removes the given data block from the materials array.
Add, Assign, Delete Materials
Table of Contents
Generally speaking Blenders (node-based) material system can be thought of as a two-part process, of material creation and material assignment, that in practice means adding, assigning or deleting materials can be done independently of an object or element selection.
Design note: for Blender 2.8+ and newer meshes need to be UV unwrapped and mapped for materials assigned an image or texture to appear on the mesh in LookDev or Rendered display modes otherwise the materials diffuse colour (Base Color) is shown. Learn more about the basics of node-based materials here.
A project shown in the 3D View comprising multiple objects, each assigned a single unique material taken from a larger pool of materials (not ordinarily visible unless objects are joined together and/or selected using Browse Material to be linked menu).
Add Material
Materials in Blender are data blocks, segments or chunks of information that define the surface (or volumetric) properties of whatever they might be assigned to or associated with. As such this means they can be created in Object Mode or Edit Mode with or without an active object or selection being made.
Design note: although no object or selection is strictly necessary, adding a new material to a project will automatically assign it to, or associated it with, the last item selected, especially if this was a mesh (depending on object selection a number of different material ‘sets’ might appear to be created because Blender defaults to assuming an association between the last selected object or item and the materials subsequently generated – a completely new set of materials can be added to different object selections – all of which then become available project-wide).
Although no objects are shown selected in the 3D View, the Outliner highlights the last item interacted with as an inactive selection, for example ‘trim’ shown in the above, new materials will be associated with this by default.
To create or add a material, in Material properties click the + (Add Material Slot) button to the right of the Material List aperture and then the + New (Add a new material) button below, once an entry appears, to populate. Alternatively click the + New button (Add a new material) below the aperture to create a new list item (index) and set of properties at the same time.
Design note: using the + button adds an ‘index’ or ‘list item’ to the Material List (the aperture displaying materials associated with the selected object) minus accompanying properties; + New places a new index and populates it with a set of default (node-based) properties – where multiple materials are being created, a multi-material, the + button inserts an index which then needs to be populated clicking +New (the + New button isn’t available once an index/instance has been populated so click + first to add an index then + New to populate).
When adding materials to a project they can be created as an initial ‘index’ or ‘list item’ without an accompanying set of material properties and options, or a list item with a set of properties, the panel below propagated with various settings and options.
Adding new materials can be done by clicking the + button to add a new index then populating with a set of material properties or, clicking the + New button to add an entry and populate at the same time.
The Material List (Material Index) displays the instances available for assignment, each accompanied by a set of properties and options.
Assign to Object (Global)
Once a material or set of materials are available they can be assigned. To do this in Object Mode, select an object 3D View then in Material properties click the Browse Material to be linked drop-down icon below-left of the Material List aperture and select an item from the list of materials shown, e.g. frame in the below. This immediately assigns the selected material to the object.
Design note: blank objects, that is objects absent material indexes or material assignments, will assume or take on the properties associated with whichever material is first assigned – subsequent applications generally don’t override this behaviour unless applied to local selections (Edit Mode).
To assign a single material to an object first make a selection then from the Browse Material to be linked drop-down menu choose an item to assign from the list shown, e.g. frame.
To assign additional materials, so two or more are associated with the selected object, with the object still selected click the + button to add a new material index, ensure this remain selected and use the Browse Material to be linked drop-down again to make a selection. The new slot will populate with properties. Repeat for however many materials need to be assigned to the item.
Important: assigning several materials to an object (in Object Mode) does not change the initial assignments influence over the object, it remains the primary reference regardless. Changing this in Object Mode means deleting all assignments (cf. below) and reordering their (re)application, or their being assigning to specific element selections in Edit Mode (cf. below); reordering the indexes as they appear in the Material List only changes display order, it does not affect the material/object relationship.
Assigning materials in Object Mode, objects will take on the properties of whichever material is assigned first – reordering the Material List does not change this.
To assign several (multiple) materials to an object a new material index has to be created which is then populated with a properties selection using the Browse Material to be linked drop-down list.
Assign to Element (Local)
Generally speaking, assigning materials in the local sense means using Edit Mode to apply them to specific element selections of an object. This is typically done when several materials need to be assigned to specific regions, areas or faces.
Design note: objects take on the properties of the first material assigned in Object Mode, which remain otherwise unaffected unless changed in Edit Mode through the addition and assignment of other materials. If materials are created and assigned entirely in Edit Mode, object mode behaviour is not generally applicable – the initial assignment won’t be automatically assigned to everything.
With an object selected, in Edit Mode make an element selection, a group of vertices, edges or faces associated with a particular mesh region or area. In Material properties click the + button to add a new material index, ensure this is selected then click the Assign button below the Material List aperture. Once done click Browse Material to be linked and select the appropriate set of properties to accompany the index.
Design note: the material index can be assigned with or without a set of properties – rather than assigning blank indexes they can be matched to a set of properties beforehand making each more easily identifiable (once matched to a set of properties each index will have a named and/or Base Color making identification easier).
Assigning material indexes to different parts of a mesh before being associated with a set of properties can make it difficult to determine what’s assigned where as nothing uniquely identifies the assignments.
To assign several (multiple) materials to an object a new material index has to be created which is then populated with a properties selection using the Browse Material to be linked drop-down list.
To assign materials to different selections of a mesh, whilst still in Edit Mode, make another selection (being mindful to clear previous selections, Alt + A ) and click the + button to add another material index, ensure this is selected then click the Assign button. Click Browse Material to be linked and select the appropriate set of properties from those available.
Design note: in Edit Mode, to test assignments select each entry in the Material List in turn then click the Select and Deselect buttons below; different parts of the mesh will highlight relative to the selected material.
Test material assignments in Edit Mode selecting entries in the Material List and click the Select and Deselect buttons below – this can only be done in Edit Mode.
Multiple materials (shown with Base Color above for clarity) can be assigned to different selections in Edit Mode clicking the Assign button once an available index or material slot is available – each can be accompanied by a set of properties or left blank (default state).
Delete Material
Design note: upon object selection the Material List only displays assigned materials then available for removal.
In the Material List click an material index entry to highlight the instance to be removed, then click the – (minus) button (Remove Material Slot) to the right of the aperture (alternatively press the Delete or X keys). The material will be disappear from the list and the object will either; a) display ‘white’ if the removed material was the only one assigned, or b) the selected element from which the material was removed will assume the properties associated with the first instance in the Material List – faces assigned ‘frame’ in the below for example will assume ‘screen’ as that is the first available index.
Important: deleting materials does not remove the material itself, the underlying data block, it simply clears the associative link between it (data block as expressed as a material) and the object or element to which it was assigned. In this way materials can be removed (partially or fully/all) from selections and remain available for (re)assignment to other objects and selections (caveat: materials absent a Fake User will be lost if the *.blend is saved and reopened).
Deleting materials removes the association between material and object/selection not the underlying data block (cf. above), which should remain available for use – caveat: materials prefixed with a ‘0’ are Fake Users, data that can be lost if the project they’re in is saved and reopened.
Materials can only be removed in object mode, which will strip the association, the selection then assuming the initial materials properties or those of the first index in the Material List – in the above ‘frame’ is removed and in doing so those faces then take on the properties of the first entry in the Material List, ‘screen’.
Delete All Materials
To batch delete some or all materials from an object, the Outliner can be used as an alternative because the Material List can only remove single instances at a time. To do this, select the object with materials to be removed and in the Outliner expand its details clicking the ► icon to the left of the appropriate mesh listing. Once assignments are shown, Shift + click each item, right-click those highlighted and then select Delete from the context menu. All the materials will be deleted from the selected object.
Design note: using the Outliner to delete materials may leave indexes in the Material List, which will need removing separately per the above – using the Outliner, as with the Material List, is only deleting the relationship between object and material(s), it does not remove the underlying data blocks.
Removing several materials at a time (batch removal) can be done using the Outliner; view the objects details and highlight the entries to be removed, right-click then select Delete from the context menu.
Delete Material Data-Blocks
Regardless as to how materials are deleted the underlying datablocks remain in place ready for reapplication. If this not wanted and materials should be removed from the file outright this can be done using the Outliner. To do this, switch the Display Mode to Blender File and expand the Materials category to reveal the assigned entries. Select the items to be removed from the file then right-click the highlighted entries, from the context menu click Delete.
Important: once removed from Blender File using the Outliner the project will need to be saved and reopened to ensure the data is cleared properly – removing data this way can occasionally give rise to orphaned data, which can be removed using the Outliner and the Orphan Data editor.
Removing materials from a project can leave data behind that’s not assigned to anything (indicated above by the column with 0’s [zero’s]), orphaned data as this is called. Use the Orphan Data editor to remove.
Removing the underlying datablocks associated with the materials being deleted in the Outliner – switch the Display Mode to Blender File, select the Materials to be removed, right-click and select Delete.
AssignmentпѓЃ
Material ‣ Material Slots
Materials are data-blocks that can be created and then assigned to one or more objects. An object can also have multiple materials assigned in different material slots, which correspond to different parts of an object. If a smooth transition between materials is desired, then mixing shader nodes with a Mix shader is a better solution.
Material SlotsпѓЃ
Material slots link materials to objects and meshes. By default objects only have a single material slot, which assigns a material to the entire object. If different parts of the mesh need different materials, multiple material slots can be created.
Material slots panel. пѓЃ
Slot ListпѓЃ
Add Material Slot
Add a new material slot on the object.
Remove Material Slot
Remove a material slot from the object.
Copy material shader nodes and settings to clipboard.
Paste material shader nodes and settings from clipboard.
Copy Material to Selected
Copy the same material assignment from the active to other selected objects.
Remove Unused Slots
Removes all material slots not assigned to the object.
Data-BlockпѓЃ
The Material Data-Block Menu for the selected material slot. Here new materials can be created, or existing materials can to the material slot.
Specifies whether the material is to be linked to the object or to the object data.
The Link selector has two choices, Data and Object. These two menu choices determine whether the material is linked to the object or to the data (e.g. a mesh or curve). The Data menu item determines that this material will be linked to the mesh’s data-block which is linked to the object’s data-block. The Object menu item determines that the material will be linked to the object’s data-block directly.
This has consequences of course. For example, different objects may share the same mesh data-block. Since this data-block defines the shape of the object any change in Edit Mode will be reflected on all of those objects. Moreover, anything linked to that mesh data-block will be shared by every object that shares that mesh. So, if the material is linked to the mesh, every object will share it.
On the other hand, if the material is linked directly to the object data-block, the objects can have different materials and still share the same mesh.
Short explanation: If connected to the object, you can have several instances of the same Object Data using different materials. If linked to mesh data, you cannot. See Data System for more information.
Edit ModeпѓЃ
To assign materials to different parts of a mesh, enter Edit Mode on the mesh. Additional buttons will then appear in the material slots panel.
Material slots panel in Edit Mode. пѓЃ
Assign active material slot and material to the selected faces in the mesh, strokes in a Grease Pencil, and similar for other object types.
Select faces assigned to the active material slot.
Deselect faces assigned to the active material slot.
Reusing Existing MaterialsпѓЃ
Blender is built to allow you to reuse anything, including material settings, between many objects. Instead of creating duplicate materials, you can simply reuse an existing material. There are several ways to do this using the Material’s data-block menu:
Single Object – With the object selected, click the sphere located to the left of the Material name. A pop-up appears showing all the materials available in the current blend-file. To use one, just click on it.
Searching for Materials
The search field at the bottom of the material list allows you to search the names in the list. For example, by entering “wood” all existent materials are filtered so that only materials containing “wood” are displayed in the list.
Deleting a MaterialпѓЃ
To delete a material, select the material and click X in the Available Materials List entry.
Although the material will seem to disappear immediately, the Delete action can depend on how the material is used elsewhere.
If the material is linked to the object and there are other objects which use this material, then the material will be removed from that object (but remain on all its other objects).
If the “Fake User” button has been lit in the Available Materials list, then the material will be retained when the file is saved, even if it has no users.
Only if it has 0 “real” users, and no “Fake” user, will the material be permanently deleted. Note that it will still remain in the Materials list until the blend-file is saved, but will have disappeared when the file is reloaded.
Multiple MaterialsпѓЃ
Normally, different colors or patterns on an object are achieved by adding textures to your materials. However, in some applications you can obtain multiple colors on an object by assigning different materials to the individual faces of the object.
To apply several materials to different faces of the same object, you use the Material Slots options in the Materials header panel.
The workflow for applying a second material to some faces of an object covered by a base material is as follows:
In Object Mode, create a base material.
Go into Edit Mode and Face Select (a new list will appear below the Active Material list with Assign, Select, Deselect buttons).
Select the faces to be colored with the second material.
In the Object Material Slots list, click the + button to create a new slot or select an existing material.
Click the Assign button, and the material will appear on the selected object faces.
© Copyright : This page is licensed under a CC-BY-SA 4.0 Int. License. Last updated on 08/14/2022.
Назначение материала¶
Также мы дадим вам подсказки о практическом использовании материалов.
Создание нового материала¶
Когда создаётся новый объект, он создаётся без привязанного материала. Создать объекту материал вы можете следующим способом:
Появится панель настроек затенения. Она содержит следующие элементы:
Добавление нового материала
Для добавления нового материала нажмите на кнопку «+» в блоке активного материала. В результате этого действия произойдёт несколько вещей:
Панель материалов с новой записью
Кнопки на панели нового материала¶
Ниже представлена подробная информация о дополнительных кнопках, появляющихся на панели материала при создании нового активного материала:
Активный материал Список с просмотром. Материал Блок данных материала для выбранного слота материала.
Хорошей идеей будет давать вашим материалам понятные имена, чтобы вы могли легко понимать, для чего они нужны, особенно, если они связаны с несколькими объектами. Постарайтесь давать материалу описательное, а не функциональное имя (например, «жёлтая раскраска» вместо «цвет кухонного стола»).
Переиспользование существующих материалов¶
Blender is built to allow you to reuse anything, including material settings, between many objects. Instead of creating duplicate materials, you can simply reuse an existing material. There are several ways to do this using the Materials data-block menu:
Одиночный объект – когда выбран объект, нажмите на сферу, расположенную слева от имени материала. Появится выпадающий список со всеми материалами, доступными в текущем blend-файле. Чтобы использовать конкретный, просто нажмите на него.
Выбор существующего материала
Поле поиска под списком материалов позволит вам искать материалы по их именам в списке. Например, введя в поле «wood» («дерево»), список отфильтруется так, что будет содержать только материалы со словом «wood» в своём имени.
Удаление материала¶
Для удаления материала выберите его и нажмите на крестик (X) на записи в списке активных материалов.
Хотя материал немедленно пропадёт, действие удаления зависит от того, используется ли этот материал где-либо ещё.
Если материал связан с объектом и существуют другие использующие его объекты, то он будет убран из этого объекта (но всё равно останется на всех остальных объектах).
Если в списке доступных материалов была нажата кнопка «Фиктивный пользователь» (F), то материал останется при сохранении файла, даже если им никто не пользуется.
Только когда у материала будет ноль «реальных» пользователей и не будет «фиктивного» пользователя, он будет окончательно удалён. Обратите внимание, что он всё ещё будет находиться в списке материалов до тех пор, пока blend-файл не будет сохранён, но пропадёт оттуда после перезагрузки файла.
Несколько материалов¶
Обычно различные цвета или узоры на объекте достигаются путём добавления текстур к вашим материалам. Однако, в некоторых приложениях вы можете получить несколько цветов на объекте путём назначения различных материалов на разные грани объекта.
Добавление нового материала
To apply several materials to different faces of the same object, you use the Material Slots options in the Materials header panel.
Меню материалов в режиме редактирования
Рабочий процесс по назначению второго материала некоторым граням объекта, уже имеющим базовый материал, следующий:
Также вы можете сделать этот новый материал копией существующего материала, путём добавления блока данных:
Select the object, get the material, RMB and Copy data to clipboard. When you have renamed the material, click «Link: Data» to link to the existing material. Proceed to assign faces as required. NB: If you change the material on the original object, the new object color changes too.
© Copyright : This page is licensed under a CC-BY-SA 4.0 Int. License.
How can I delete a large amount of Materials?
This is from one of the models I have already setup and rendered. In the actual model I’ve cleaned up all those materials and setup my own which number 15-20. In spite of this these materials still remain in my file and slow down my work.
I have tried using the delete addon I’ve seen in some answers to this question but that only leads to Blender crashing. Manually removing them with the «Minus» is out of the question, I’ve done it before for single instances. Having 3-4 models with 5000-6000 materials is not timewise efficient.
2 Answers 2
There are two ways to approach this problem. There’s a tedious easy one, and there’s a programmatic complex one.
The tedious answer has been alluded to in the existing answer and a couple of comments. I.e. Blender is designed to delete (skip saving) any «orphaned» data block, like a material, anytime you save a scene. Consequently, if you remove those materials from any objects so that they’re not being used by anything, then when you close Blender and reopen the scene, they should no longer be there. There is a way, though, to force Blender to keep an unused data block, by giving it a «Fake user» by clicking the ‘F’ next to its name in the object tab. This makes the data block seem used, so that it doesn’t get deleted when Blender closes. The solution is to (tediously) remove all of those materials from any object that’s using them. Then close the scene.
The programmatic solution is to write a Python script which will do a lot of this for you. Depending on what your objective is, you might have the script look at each material, find the object(s) it’s assigned to, and replace the duplicate material with some other material, so that all your objects are using the same material. There are other ways to approach the design, depending on what your goals are, but all of them should be relatively simple. For example, this script is very short, and does some things sort of similar to what you’re trying to do to. maybe.
Источники информации:
- http://www.katsbits.com/codex/delete-material/
- http://docs.blender.org/manual/en/latest/render/materials/assignment.html
- http://docs.blender.org/manual/ru/2.79/render/blender_render/materials/assigning_a_material.html
- http://blender.stackexchange.com/questions/87391/how-can-i-delete-a-large-amount-of-materials