[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29363] trunk/blender/release/scripts/ modules/bpy_types.py: python utility property library.users_id: returns a tuple of all ID datablocks which use this library.

Campbell Barton ideasman42 at gmail.com
Wed Jun 9 11:48:41 CEST 2010


Revision: 29363
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29363
Author:   campbellbarton
Date:     2010-06-09 11:48:41 +0200 (Wed, 09 Jun 2010)

Log Message:
-----------
python utility property library.users_id: returns a tuple of all ID datablocks which use this library.

Modified Paths:
--------------
    trunk/blender/release/scripts/modules/bpy_types.py

Modified: trunk/blender/release/scripts/modules/bpy_types.py
===================================================================
--- trunk/blender/release/scripts/modules/bpy_types.py	2010-06-09 09:08:34 UTC (rev 29362)
+++ trunk/blender/release/scripts/modules/bpy_types.py	2010-06-09 09:48:41 UTC (rev 29363)
@@ -38,6 +38,24 @@
         return new_context
 
 
+class Library(bpy_types.ID):
+    __slots__ = ()
+
+    @property
+    def users_id(self):
+        """ID datablocks which use this library"""
+        import bpy
+
+        # See: readblenentry.c, IDTYPE_FLAGS_ISLINKABLE, we could make this an attribute in rna.
+        attr_links = "actions", "armatures", "brushes", "cameras", \
+                "curves", "gpencil", "groups", "images", \
+                "lamps", "lattices", "materials", "metaballs", \
+                "meshes", "node_groups", "objects", "scenes", \
+                "sounds", "textures", "texts", "fonts", "worlds"
+
+        return tuple(id_block for attr in attr_links for id_block in getattr(bpy.data, attr) if id_block.library == self)
+
+
 class Texture(bpy_types.ID):
     __slots__ = ()
 





More information about the Bf-blender-cvs mailing list