diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-06-09 13:48:41 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-06-09 13:48:41 +0400 |
commit | 0ef243122032307f225033bc5454b6fe20fe09ad (patch) | |
tree | 9e3bad93f76e993d368fc95262a563a28af7ee28 /release | |
parent | c023cd20fc5d6c03b389a197fdb2c081155e4a3e (diff) |
python utility property library.users_id: returns a tuple of all ID datablocks which use this library.
Diffstat (limited to 'release')
-rw-r--r-- | release/scripts/modules/bpy_types.py | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index d33b43f2e58..bec127138af 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -38,6 +38,24 @@ class Context(StructRNA): 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__ = () |