Fix object.users_collection not including scene collections.
authorBrecht Van Lommel <brechtvanlommel@gmail.com>
Thu, 7 Feb 2019 11:59:40 +0000 (12:59 +0100)
committerBrecht Van Lommel <brechtvanlommel@gmail.com>
Thu, 7 Feb 2019 12:01:01 +0000 (13:01 +0100)
release/scripts/modules/bpy_types.py

index f12b259..32e8fe4 100644 (file)
@@ -120,10 +120,12 @@ class Object(bpy_types.ID):
 
     @property
     def users_collection(self):
-        """The collections this object is in. Warning: takes O(len(bpy.data.collections)) time."""
+        """The collections this object is in. Warning: takes O(len(bpy.data.collections) + len(bpy.data.scenes)) time."""
         import bpy
         return tuple(collection for collection in bpy.data.collections
-                     if self in collection.objects[:])
+                     if self in collection.objects[:]) + \
+               tuple(scene.collection for scene in bpy.data.scenes
+                     if self in scene.collection.objects[:])
 
     @property
     def users_scene(self):