Utilities (bpy.utils)
This module contains utility functions specific to blender but
not assosiated with blenders internal data.
-
bpy.utils.blend_paths(absolute=False, packed=False, local=False)
Returns a list of paths to external files referenced by the loaded .blend file.
Parameters: |
- absolute (boolean) – When true the paths returned are made absolute.
- packed (boolean) – When true skip file paths for packed data.
- local (boolean) – When true skip linked library paths.
|
Returns: | path list.
|
Return type: | list of strings
|
-
bpy.utils.register_class(cls)
Register a subclass of a blender type in (bpy.types.Panel,
bpy.types.Menu, bpy.types.Header, bpy.types.Operator,
bpy.types.KeyingSetInfo, bpy.types.RenderEngine).
If the class has a register class method it will be called
before registration.
Note
ValueError exception is raised if the class is not a
subclass of a registerable blender class.
-
bpy.utils.resource_path(type, major=2, minor=57)
Return the base path for storing system files.
Parameters: |
- type (string) – string in [‘USER’, ‘LOCAL’, ‘SYSTEM’].
- major (int) – major version, defaults to current.
- minor (string) – minor version, defaults to current.
|
Returns: | the resource path (not necessarily existing).
|
Return type: | string
|
-
bpy.utils.unregister_class(cls)
Unload the python class from blender.
If the class has an unregister class method it will be called
before unregistering.
-
bpy.utils.keyconfig_set(filepath)
-
bpy.utils.load_scripts(reload_scripts=False, refresh_scripts=False)
Load scripts and run each modules register function.
Parameters: |
- reload_scripts (bool) – Causes all scripts to have their unregister method
called before loading.
- refresh_scripts (bool) – only load scripts which are not already loaded
as modules.
|
-
bpy.utils.modules_from_path(path, loaded_modules)
Load all modules in a path and return them as a list.
Parameters: |
- path (string) – this path is scanned for scripts and packages.
- loaded_modules (set) – already loaded module names, files matching these
names will be ignored.
|
Returns: | all loaded modules.
|
Return type: | list
|
-
bpy.utils.preset_find(name, preset_path, display_name=False)
-
bpy.utils.preset_paths(subdir)
Returns a list of paths for a specific preset.
Parameters: | subdir (string) – preset subdirectory (must not be an absolute path). |
Returns: | script paths. |
Return type: | list |
-
bpy.utils.refresh_script_paths()
Run this after creating new script paths to update sys.path
-
bpy.utils.register_module(module, verbose=False)
-
bpy.utils.script_paths(subdir=None, user_pref=True, check_all=False)
Returns a list of valid script paths.
Parameters: |
- subdir (string) – Optional subdir.
- user_pref (bool) – Include the user preference script path.
- check_all (bool) – Include local, user and system paths rather just the paths
blender uses.
|
Returns: | script paths.
|
Return type: | list
|
-
bpy.utils.smpte_from_frame(frame, fps=None, fps_base=None)
Returns an SMPTE formatted string from the frame: “HH:MM:SS:FF”.
If fps and fps_base are not given the current scene is used.
-
bpy.utils.smpte_from_seconds(time, fps=None)
Returns an SMPTE formatted string from the time in seconds: “HH:MM:SS:FF”.
If the fps is not given the current scene is used.
-
bpy.utils.unregister_module(module, verbose=False)
-
bpy.utils.user_resource(type, path='', create=False)
Return a user resource path (normally from the users home directory).
Parameters: |
- type (string) – Resource type in [‘DATAFILES’, ‘CONFIG’, ‘SCRIPTS’, ‘AUTOSAVE’].
- subdir (string) – Optional subdirectory.
- create (boolean) – Treat the path as a directory and create
it if its not existing.
|
Returns: | a path.
|
Return type: | string
|
-
bpy.utils.user_script_path()