From a695741a4858b429f17db6e9cce6a171c32d769d Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 25 Aug 2010 01:22:50 +0000 Subject: updates to blender rna api --- space_view3d_materials_utils.py | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) (limited to 'space_view3d_materials_utils.py') diff --git a/space_view3d_materials_utils.py b/space_view3d_materials_utils.py index 0a2abea3..d3c8252c 100644 --- a/space_view3d_materials_utils.py +++ b/space_view3d_materials_utils.py @@ -398,25 +398,23 @@ def check_texture(img,mat): #makes a texture if needed #adds it to the material if it isn't there already - try: - tex = bpy.data.textures[img.name] - except: - tex = bpy.data.textures.new(name=img.name) - finally: - tex.type = 'IMAGE' - tex = tex.recast_type() - tex.image = img - - #see if the material already uses this tex - #add it if needed - found = False - for m in mat.texture_slots: - if m and m.texture == tex: - found = True - break - if not found and mat: - mat.add_texture(tex, texture_coordinates='UV', map_to='COLOR') - + tex = bpy.data.textures.get(img.name) + + if tex is None: + tex = bpy.data.textures.new(name=img.name, type='IMAGE') + + tex.image = img + + #see if the material already uses this tex + #add it if needed + found = False + for m in mat.texture_slots: + if m and m.texture == tex: + found = True + break + if not found and mat: + mat.add_texture(tex, texture_coordinates='UV', map_to='COLOR') + def texface_to_mat(): # editmode check here! editmode = False -- cgit v1.2.3