diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-08-25 05:22:50 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-08-25 05:22:50 +0400 |
commit | a695741a4858b429f17db6e9cce6a171c32d769d (patch) | |
tree | 0b156ec707bda32e7c097a832dbf04353517fa05 /space_view3d_materials_utils.py | |
parent | 980d7fe327a1ae874939b9ca04b3697396f49299 (diff) |
updates to blender rna api
Diffstat (limited to 'space_view3d_materials_utils.py')
-rw-r--r-- | space_view3d_materials_utils.py | 36 |
1 files changed, 17 insertions, 19 deletions
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 |