texture user attributes, users_material, users_object_modifier
authorCampbell Barton <ideasman42@gmail.com>
Tue, 8 Jun 2010 13:03:49 +0000 (13:03 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Tue, 8 Jun 2010 13:03:49 +0000 (13:03 +0000)
release/scripts/modules/bpy_types.py

index 28a30c232a9483594c4591422278171d5b7b2b72..d33b43f2e58360a42a82083afc010a2a1d424bbb 100644 (file)
@@ -38,6 +38,22 @@ class Context(StructRNA):
         return new_context
 
 
+class Texture(bpy_types.ID):
+    __slots__ = ()
+
+    @property
+    def users_material(self):
+        """Materials that use this texture"""
+        import bpy
+        return tuple(mat for mat in bpy.data.materials if self in [slot.texture for slot in mat.texture_slots if slot])
+
+    @property
+    def users_object_modifier(self):
+        """Object modifiers that use this texture"""
+        import bpy
+        return tuple(obj for obj in bpy.data.objects if self in [mod.texture for mod in obj.modifiers if mod.type == 'DISPLACE'])
+
+
 class Group(bpy_types.ID):
     __slots__ = ()