Utilities (bpy.utils)

This module contains utility functions specific to blender but not assosiated with blenders internal data.

bpy.utils.addon_check(module_name)

Returns the loaded state of the addon.

Parameters:
  • module_name (string) – The name of the addon and module.
Returns:

(loaded_default, loaded_state)

Return type:

tuple of booleans

bpy.utils.addon_disable(module_name, default_set=True)

Disables an addon by name.

Parameters:
  • module_name (string) – The name of the addon and module.
bpy.utils.addon_enable(module_name, default_set=True)

Enables an addon by name.

Parameters:
  • module_name (string) – The name of the addon and module.
Returns:

the loaded module or None on failier.

Return type:

module

bpy.utils.addon_reset_all()

Sets the addon state based on the user preferences.

bpy.utils.blend_paths(absolute=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.
Returns:

path list.

Return type:

list of strigs

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.

bpy.utils.script_paths(subdir=None, user=True)

Returns a list of valid script paths from the home directory and user preferences.

Accepts any number of string arguments which are joined to make a path.

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.user_resource(type, subdir)

Returns a list of paths to external files referenced by the loaded .blend file.

Parameters:
  • type (string) – Resource type in [‘DATAFILES’, ‘CONFIG’, ‘SCRIPTS’, ‘AUTOSAVE’].
  • subdir (string) – Optional subdirectory.
Returns:

a path.

Return type:

string

bpy.utils.user_script_path()

Previous topic

bpy_struct

Next topic

Path Utilities (bpy.path)