image problem

hello,
could anyone explain why this doesnt work? Ive tried it with blender 2.42a and a cvs build from 29/1

the output from running the script twice is included.


import Blender
from Blender import Scene
from Blender import NMesh
from Blender import Image

print 
print "start"

def doObj(obj):
	if obj.getType() != 'Mesh':
		return 
	data = obj.getData()
	
	lightmap_name = "lightmap_%s" % obj.name
	try:
		image = Image.Get(lightmap_name)
	except NameError:
		image = Image.New(lightmap_name, 512, 512, 24)
		
	for face in data.faces:
		print "was", face.image
		face.image = image
		print "now", face.image
	
	
def doScene(scene):
	for obj in scene.getChildren():
		doObj(obj)
		
		
scene = Scene.GetCurrent()
doScene(scene)

##########################
# first run 
start
was None
now [Image "lightmap_Cube"]
was None
now [Image "lightmap_Cube"]
was None
now [Image "lightmap_Cube"]
was None
now [Image "lightmap_Cube"]
was None
now [Image "lightmap_Cube"]
was None
now [Image "lightmap_Cube"]

#second run 
start
was None
now [Image "lightmap_Cube"]
was None
now [Image "lightmap_Cube"]
was None
now [Image "lightmap_Cube"]
was None
now [Image "lightmap_Cube"]
was None
now [Image "lightmap_Cube"]
was None
now [Image "lightmap_Cube"]


it seems if I use Mesh instead of NMesh the code does work.


data = obj.getData(False, True)

anyone know why?

personally I like Mesh a lot better then NMesh :wink:

But data.update() would have worked also.