Fix T63764: error when using library.users_id() function
[blender.git] / release / scripts / modules / bpy_types.py
index 32e8fe40c6adc9f60faea8e1e5ef96a24411d00c..86fb09ffb4b8e947246164351c90d15cf1fdf8bf 100644 (file)
@@ -61,7 +61,7 @@ class Library(bpy_types.ID):
         # See: readblenentry.c, IDTYPE_FLAGS_ISLINKABLE,
         # we could make this an attribute in rna.
         attr_links = ("actions", "armatures", "brushes", "cameras",
         # See: readblenentry.c, IDTYPE_FLAGS_ISLINKABLE,
         # we could make this an attribute in rna.
         attr_links = ("actions", "armatures", "brushes", "cameras",
-                      "curves", "grease_pencil", "collections", "images",
+                      "curves", "grease_pencils", "collections", "images",
                       "lights", "lattices", "materials", "metaballs",
                       "meshes", "node_groups", "objects", "scenes",
                       "sounds", "speakers", "textures", "texts",
                       "lights", "lattices", "materials", "metaballs",
                       "meshes", "node_groups", "objects", "scenes",
                       "sounds", "speakers", "textures", "texts",
@@ -523,6 +523,15 @@ class Text(bpy_types.ID):
         self.clear()
         self.write(string)
 
         self.clear()
         self.write(string)
 
+    def as_module(self):
+        from os.path import splitext
+        from types import ModuleType
+        mod = ModuleType(splitext(self.name)[0])
+        # TODO: We could use Text.compiled (C struct member)
+        # if this is called often it will be much faster.
+        exec(self.as_string(), mod.__dict__)
+        return mod
+
 
 class Sound(bpy_types.ID):
     __slots__ = ()
 
 class Sound(bpy_types.ID):
     __slots__ = ()