diff options
Diffstat (limited to 'release/scripts/modules/bpy_types.py')
-rw-r--r-- | release/scripts/modules/bpy_types.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/release/scripts/modules/bpy_types.py b/release/scripts/modules/bpy_types.py index 32e8fe40c6a..fb4ccfaff7a 100644 --- a/release/scripts/modules/bpy_types.py +++ b/release/scripts/modules/bpy_types.py @@ -523,6 +523,15 @@ class Text(bpy_types.ID): 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__ = () |