1
$\begingroup$

How can I remove any mesh, texture, material and others from a Blend file? Now I have a single scene with one object that has no material, nothing is hidden, I am not in local mode, I tried every File/Clean Up/... commands, but yet there are a lot of previously used textures, meshes and other stuffs in the Blend file. Is there a way to get rid of them without manually hunting them one by one?

I wonder if Blender has a one click solutin for efficient clean up/purge functionality.

An example file: https://easyupload.io/7f3e2c

$\endgroup$
10
  • $\begingroup$ Have you tried to switch to Orphan Data in the Outliner then click on the Purge button? $\endgroup$
    – moonboots
    Aug 13, 2021 at 8:01
  • $\begingroup$ Yes, but I found only factory brushes there, none of my own orphan data. Hard to believe, that no way to solve such a simple and every day task. For an average programmer this is a 1 hour project. A simple tree traversal. Why Blender developers don't take care for it? $\endgroup$
    – Denatural
    Aug 13, 2021 at 8:35
  • $\begingroup$ it means that all other datas than brushes are used by at least one object $\endgroup$
    – moonboots
    Aug 13, 2021 at 8:38
  • $\begingroup$ No. As I wrote, I have one scene, one object in that. Tha object has no material. It is default white. There are no hidden objects in the scene. I just read about it, and found this post: blenderartists.org/t/how-do-you-actually-purge-unused-data/… $\endgroup$
    – Denatural
    Aug 13, 2021 at 8:42
  • $\begingroup$ yes that's weird, the other possibility is that you've pressed on the Fake User button for some textures, but could you please share your object (at least a part of it)? pasteall.org/blend $\endgroup$
    – moonboots
    Aug 13, 2021 at 8:44

2 Answers 2

1
$\begingroup$

Not unused, rather not linked to scene.

There are no orphans in the blend file. For example running script here details this object has 16 users, and "who" they are

---------------------------------
bpy.data.objects['tümpanon blokk']
Users: 16
("bpy.data.objects['Ablak4_Ablak4.057']", "bpy.data.objects['Ablak4_Ablak4.058']", "bpy.data.objects['Ablak4_Ablak4.059']", "bpy.data.objects['Ablak4_Ablak4.060']", "bpy.data.objects['Cimer_Circle']", "bpy.data.objects['Cimer_Circle.002']", "bpy.data.objects['Proba_Cube.001']", "bpy.data.objects['Proba_Cube.003']")

and as mentioned by Cranzitz likely these objects are linked together via pointers used by an addon, perhaps these custom properties give a clue...

>>> C.object['
              bc']
              graswald']
              hops']
              kitops']
              lod_original']

To deal with these can remove all objects not linked to the scene. Here is a script to do much the same as select all but one object in outliner data API UI as suggested. In this case select all objects not used by a scene

import bpy

obs = [o for o in bpy.data.objects
        if not o.users_scene]
        
bpy.data.batch_remove(obs)

after which any meshes etc left over will be mostly orphaned and can be dealt with accordingly.

enter image description here

Removing kitops.

Further to the reasons this happens, an addon like kitops associates objects via pointers to other objects, effectively upping the user count and leading to

Object referenced by PointerProperty in Python can not be deleted properly

Not deleting objects with users is a safety feature. IMO perhaps the makers of the addons could add an operator to remove those dependencies.

For example this script will remove the custom property added by kitops

import bpy

for o in bpy.data.objects:
    del(o["kitops"])

leading to a number of objects appearing as orphans.

$\endgroup$
3
  • $\begingroup$ Wow! Cool! Your 3 line script solved the problem! Now the clean up found every unused stuffs, the file size dropped from 11 MB to 3 MB and the inner structure is nice clean, not a huge trash can. I don't understand, why isn't this part of the default clean up function. I will create a menu item from this script. $\endgroup$
    – Denatural
    Aug 13, 2021 at 15:47
  • $\begingroup$ THanks. Added an edit to explain somewhat. $\endgroup$
    – batFINGER
    Aug 13, 2021 at 16:26
  • $\begingroup$ I don't think Blender should rely on third party addon developers. There are a lot of addon with many-many bugs, the most addon developer is not even professional coder, or has not enough knowledge of Blender API. So Blender has to provide a robust framework, and if user want to clean everything that is not effect the actual scene, it shoud delete it mercylessly. Or ask user, what to do if pointers found referenced to unknown sources. $\endgroup$
    – Denatural
    Aug 13, 2021 at 17:00
1
$\begingroup$

I'm pretty sure that you use some specific add-on like kitops, because the objects that you are talking about used somehow. You can see this by number of users, that currently is one:

enter image description here

but should be zero to be removed by Blender's clear purge data command. In this case, I belive the best way to remove it is to open the Outliner in Blender File mode:

enter image description here

Select objects that you want to remove using Shift (objects that are not presented in the scene marked by gray color, so it is easy to select right ones) then press X to remove (or from context menu):

enter image description here

Then you can use File -> Clean Up -> Recursive unused data-blocks for removing all related data like Meshes, materials ant textures.

$\endgroup$
2
  • $\begingroup$ Definately kitops is one. $\endgroup$
    – batFINGER
    Aug 13, 2021 at 13:27
  • $\begingroup$ Yes, I used Kit ops, that is very useful for cutting out a lot of windows precisely, placing ornaments and other, repetitive, boring task. $\endgroup$
    – Denatural
    Aug 13, 2021 at 15:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .