[Bf-blender-cvs] [58a12594690] master: Fix object.users_collection not including scene collections.

Brecht Van Lommel noreply at git.blender.org
Thu Feb 7 13:04:17 CET 2019


Commit: 58a12594690a556afd0ea1a97eb5d6496e7b50b9
Author: Brecht Van Lommel
Date:   Thu Feb 7 12:59:40 2019 +0100
Branches: master
https://developer.blender.org/rB58a12594690a556afd0ea1a97eb5d6496e7b50b9

Fix object.users_collection not including scene collections.

===================================================================

M	release/scripts/modules/bpy_types.py

===================================================================

diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py
index f12b259362a..32e8fe40c6a 100644
--- a/release/scripts/modules/bpy_types.py
+++ b/release/scripts/modules/bpy_types.py
@@ -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):



More information about the Bf-blender-cvs mailing list