fabex.utilities.addon_utils#

Fabex ‘addon_utils.py’ © 2012 Vilem Novak

Functions#

addon_dependencies()

Checks for and installs Blender addon dependencies.

python_dependencies()

Checks for and installs Python library dependencies.

load_defaults(addon_prefs)

Assigns scene settings based on user preferences.

copy_if_not_exists(src, dst)

Copy a file from source to destination if it does not already exist.

copy_presets(addon_prefs)

Copies Presets from the addon to Blender's Script Directory

on_blender_startup(context)

Checks for any broken computations on load and resets them.

on_engine_change(*args)

Callback function to setup Fabex when activated.

fix_units()

Set up units for Fabex.

keymap_register()

Adds a Keyboard Shortcut to the Active Key Config

keymap_unregister()

Removes a Keyboard Shortcut from the Active Key Config

add_asset_library()

Installs the Fabex Asset Library.

add_workspace()

Installs the Fabex Workspace

add_collections()

Adds color-coded Collection folders to the scene.

edit_user_post_processor()

Open and Edit the User Post Processor file in the Text Editor

append_asset_from_library(asset_type, asset_name)

Append an Asset from the Fabex Asset Library

Module Contents#

addon_dependencies()[source]#

Checks for and installs Blender addon dependencies.

This function installs a number of addons that previously came with Blender, but now have to be downloaded from an online repository. It checks for the addon in the users Blender install, and if it can’t find them, attempts to download them from Blender.

python_dependencies()[source]#

Checks for and installs Python library dependencies.

This function checks for required Python packages. These should be installed via the included ‘wheels’, but if there is a version mismatch this function will attempt to install them via pip.

load_defaults(addon_prefs)[source]#

Assigns scene settings based on user preferences.

When Fabex is activated it will restore the user’s scene settings. This includes the interface level (Beginner - Experimental), viewport shading, panel layout and machine preset.

copy_if_not_exists(src, dst)[source]#

Copy a file from source to destination if it does not already exist.

This function checks if the destination file exists. If it does not, the function copies the source file to the destination using a high-level file operation that preserves metadata.

Parameters:
  • src (str) – The path to the source file to be copied.

  • dst (str) – The path to the destination where the file should be copied.

copy_presets(addon_prefs)[source]#

Copies Presets from the addon to Blender’s Script Directory

This function copies new presets without overwriting the existing presets, unless it detects that the presets have not been updated to the current spec, in which case it will overwrite them with the addon presets.

on_blender_startup(context)[source]#

Checks for any broken computations on load and resets them.

This function verifies the presence of necessary Blender add-ons and installs any that are missing. It also resets any ongoing computations in CAM operations and sets the interface level to the previously used level when loading a new file. If the add-on has been updated, it copies the necessary presets from the source to the target directory. Additionally, it checks for updates to the CAM plugin and updates operation presets if required.

Parameters:

context – The context in which the function is executed, typically containing information about the current Blender environment.

on_engine_change(*args)[source]#

Callback function to setup Fabex when activated.

In combination with a message bus (msgbus) listener, this function will run when the Render Engine is changed. If it detects that Fabex is active it will call the required setup functions, and log the Fabex activation.

fix_units()[source]#

Set up units for Fabex.

This function configures the unit settings for the current Blender scene. It sets the rotation system to degrees and the scale length to 1.0, ensuring that the units are appropriately configured for use within Fabex.

keymap_register()[source]#

Adds a Keyboard Shortcut to the Active Key Config

This function binds the keyboard shortcut ‘Alt+C’ to the Fabex Pie Menu, and adds that shortcut to the user’s active key configuration.

keymap_unregister()[source]#

Removes a Keyboard Shortcut from the Active Key Config

This function removes the keyboard shortcut ‘Alt+C’ from the user’s active key configuration.

add_asset_library()[source]#

Installs the Fabex Asset Library.

This function adds the /assets/ folder from Fabex to the users’ Asset Library, which adds a number of Material and Geometry Node assets.

add_workspace()[source]#

Installs the Fabex Workspace

This function adds the Fabex Workspace to the users’ default Blender startup scene.

add_collections()[source]#

Adds color-coded Collection folders to the scene.

This function adds three collections to aid in scene management. Bridges, Paths and Simulations are now auto-sorted into their own collections upon creation, which can be shown or hidden as groups.

edit_user_post_processor()[source]#

Open and Edit the User Post Processor file in the Text Editor

This function finds the path to the ‘user.py’ post processor file and opens it for editing in Blender’s Text Editor. In order to open the file Blender’s Context must be overridden to ensure the Text Editor actions can run no matter what Context the user is currently in.

append_asset_from_library(asset_type, asset_name)[source]#

Append an Asset from the Fabex Asset Library

This function adds an asset from the Fabex Asset Library to the current file. The path to the library is automatically filled, but the user must provide the type and name of the asset they wish to append. Currently the library contains materials, node groups and scenes, and separate logic is provided for each.