Request: Please add on a "remove all instances of image

The interface, modeling, 3d editing tools, import/export, feature requests, etc

Moderators: jesterKing, stiv

Post Reply
Doogs
Posts: 41
Joined: Wed Oct 16, 2002 1:16 am

Request: Please add on a "remove all instances of image

Post by Doogs »

I think the method of ridding an excess image/texture file from the blender data image menu is really in need of repair. To get "rid" of an image, you have to erase all instances manually and then save, close, load, and repeat at times, until the reference to that image is gone. Please improve this?

RonC

z3r0_d
Posts: 289
Joined: Wed Oct 16, 2002 2:38 am
Contact:

Post by z3r0_d »

one could pretty easily make a script to do that

I think I shall

z3r0_d
Posts: 289
Joined: Wed Oct 16, 2002 2:38 am
Contact:

Post by z3r0_d »

peculair, you can't seem to assign None to a nmface.image

Code: Select all

TypeError: expected image object
oh well, I guess you're only going to get to replace images

Code: Select all

#!BPY
"""
Name: 'Replace Images'
Blender: 233
Group: 'Object'
Tooltip: 'Replace an image in all selected objects with another'
"""
import Blender

"""
this script's goal is to delete an image from all selected objects

it probably could be rather trivially modified to replace that image with another
"""
images = []
for obj in Blender.Object.GetSelected():
	if obj.getType() != "Mesh": continue
	for face in obj.getData().faces:
		if images.count(face.image) == 0:
			images.append(face.image)

# prompt the user which image to delete
# I probably want to sort them....
def cmpfn(x,y):
	ax = x
	ay = y
	if not ax: ax = "~~~~None"
	else: ax = ax.name
	if not ay: ay = "~~~~None"
	else: ay = ay.name
	if ax < ay: return -1
	if ax == ay: return 0
	return 1
images.sort(cmpfn)

promptst = "Select Image to Replace%t"
for i in range(len(images)):
	if not images[i]:
		promptst += "|None%x"+str(i)
	else:
		promptst += "|" + images[i].name + "%x"+str(i)

choice = Blender.Draw.PupMenu(promptst,24)

srcimg = images[choice]
if choice != -1:
	# prompt user for image to replace with
	promptst = "Select Image to Replace With%t"
	
	images = Blender.Image.Get()
	images.sort(cmpfn)
	
	for i in range(len(images)):
		if not images[i]: # doubt this will be used
			promptst += "|None%x"+str(i)
		else:
			promptst += "|" + images[i].name + "%x"+str(i)
	
	choice = Blender.Draw.PupMenu(promptst,24)
	
	if choice != -1:
		destimg = images[choice]
		for obj in Blender.Object.GetSelected():
			if obj.getType() != "Mesh": continue
			mesh = obj.getData()
			for face in mesh.faces:
				if face.image == srcimg:
					face.image = destimg
			mesh.update()
		print "###replaced images successfully"

Monkeyboi
Posts: 251
Joined: Tue Nov 26, 2002 1:24 pm
Location: Copenhagen, Denmark
Contact:

Post by Monkeyboi »

I agree Doogs, this is a huge frustration! Should be able to do this from the OOPS Schematic by selecting the image node and simply deleting it, which would remove the image completely from the file.

fligh
Posts: 31
Joined: Mon Dec 30, 2002 11:28 pm
Location: US

Post by fligh »

LOL Doogs! X the texture, Ctrl-W, Ctrl-O. But I know what you mean. Personally, I prefer it the way it is but with the new Fake option the O-user has become a bit redundant.

%<

joeri
Posts: 96
Joined: Fri Jan 10, 2003 6:41 pm
Contact:

Post by joeri »

It gets a bit more complicated with the 'packed' feature on.

Doogs
Posts: 41
Joined: Wed Oct 16, 2002 1:16 am

Post by Doogs »

Okay but does that in any way give a proper excuse to not code in "remove all instances"?

RonC

joeri
Posts: 96
Joined: Fri Jan 10, 2003 6:41 pm
Contact:

Post by joeri »

In my opinion there is no proper excuse to not have a "empty trash".
And then I consider all 0 user datablocks to be in "the trashcan".
That is, the excuse I have are my poor programming skills.

I'd also favour a "hee, thats the same image file on disk, why do I have that thing 3 times in memory" removal button, although it's might need a different name to fit in the button. Specialy for packed files on the web it's a pain to dl the same image more then once.

Doogs
Posts: 41
Joined: Wed Oct 16, 2002 1:16 am

Post by Doogs »

Do coders even look at these requests?

:(

RonC

Post Reply