Skip to main content
cleaned up indendation problems
Source Link
MaVCArt
  • 609
  • 5
  • 9

if you want to do it via code, you could take a couple of approaches:

this removes all images in the blender file:

import bpy # iterate over all images in the file for image in bpy.data.images:     # don't do anything if notthe image has any users. if image.users:   continue  # remove the image otherwise  bpy.data.images.remove(image) 

You also have the option to make this into a method that you can just pass the image to that you want to delete:

def cleanDataBlockclean_data_block(block):  # iterate over every entry in the data block  for data in block:     # if notthe data block has any users, don't do anything if data.users: continue   # otherwise remove the data block block.remove(data) 

in this case you would clean the images that were not used by using:

cleanDataBlockclean_data_block(bpy.data.images) 

if you want to do it via code, you could take a couple of approaches:

this removes all images in the blender file:

import bpy for image in bpy.data.images: if not image.users: bpy.data.images.remove(image) 

You also have the option to make this into a method that you can just pass the image to that you want to delete:

def cleanDataBlock(block): for data in block: if not data.users: block.remove(data) 

in this case you would clean the images that were not used by using:

cleanDataBlock(bpy.data.images) 

if you want to do it via code, you could take a couple of approaches:

this removes all images in the blender file:

import bpy # iterate over all images in the file for image in bpy.data.images:     # don't do anything if the image has any users. if image.users:   continue  # remove the image otherwise  bpy.data.images.remove(image) 

You also have the option to make this into a method that you can just pass the image to that you want to delete:

def clean_data_block(block):  # iterate over every entry in the data block  for data in block:     # if the data block has any users, don't do anything if data.users: continue   # otherwise remove the data block block.remove(data) 

in this case you would clean the images that were not used by using:

clean_data_block(bpy.data.images) 

if you want to do it via code, you could take a couple of approaches:

this removes all images in the blender file:

import bpy for image in bpy.data.images: if not image.users: bpy.data.images.remove(image) 

You also have the option to make this into a method that you can just pass the image to that you want to delete:

def cleanDataBlock(self,block): for data in block: if not data.users: block.remove(data) 

in this case you would clean the images that were not used by using:

cleanDataBlock(bpy.data.images) 

if you want to do it via code, you could take a couple of approaches:

this removes all images in the blender file:

import bpy for image in bpy.data.images: if not image.users: images.remove(image) 

You also have the option to make this into a method that you can just pass the image to that you want to delete:

def cleanDataBlock(self,block): for data in block: if not data.users: block.remove(data) 

in this case you would clean the images that were not used by using:

cleanDataBlock(bpy.data.images) 

if you want to do it via code, you could take a couple of approaches:

this removes all images in the blender file:

import bpy for image in bpy.data.images: if not image.users: bpy.data.images.remove(image) 

You also have the option to make this into a method that you can just pass the image to that you want to delete:

def cleanDataBlock(block): for data in block: if not data.users: block.remove(data) 

in this case you would clean the images that were not used by using:

cleanDataBlock(bpy.data.images) 
Source Link
MaVCArt
  • 609
  • 5
  • 9

if you want to do it via code, you could take a couple of approaches:

this removes all images in the blender file:

import bpy for image in bpy.data.images: if not image.users: images.remove(image) 

You also have the option to make this into a method that you can just pass the image to that you want to delete:

def cleanDataBlock(self,block): for data in block: if not data.users: block.remove(data) 

in this case you would clean the images that were not used by using:

cleanDataBlock(bpy.data.images)