Pressing the “Purge” button cleans the current open scene – removes all unused objects from it (mesh, nodes, materials, textures, etc.). However, this button is located very inconveniently, in the Outliner header and is visible only in the “Orphan Data” Outliner mode. For quick access to this button we can move it to the header of the 3D Viewport.
Clicking on the “Purge” button invokes the “outliner.orphans_purge” operator.
Let’s write a function for drawing a button that will call this operator:
1 2 |
def purge_button(self, context): self.layout.operator("outliner.orphans_purge", text="Purge") |
And add this function to the header of the 3D Viewport area:
1 |
bpy.types.VIEW3D_HT_tool_header.prepend(purge_button) |
Full code:
1 2 3 4 5 6 |
import bpy def purge_button(self, context): self.layout.operator("outliner.orphans_purge", text="Purge") bpy.types.VIEW3D_HT_tool_header.prepend(purge_button) |
After executing this code in the Text Editor, a “Purge” button will be added to the 3D Viewport header. Pressing it will call the removal of unused objects in the same way as from the Outliner.