Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-08-25 05:22:50 +0400
committerCampbell Barton <ideasman42@gmail.com>2010-08-25 05:22:50 +0400
commita695741a4858b429f17db6e9cce6a171c32d769d (patch)
tree0b156ec707bda32e7c097a832dbf04353517fa05 /space_view3d_materials_utils.py
parent980d7fe327a1ae874939b9ca04b3697396f49299 (diff)
updates to blender rna api
Diffstat (limited to 'space_view3d_materials_utils.py')
-rw-r--r--space_view3d_materials_utils.py36
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