diegogarciahuerta / tk-blender

:milk_glass: Shotgun Toolkit Engine for Blender: https://www.blender.org/
Other
44 stars 33 forks source link

BLENDER_USER_SCRIPTS overrides local user scripts #7

Open danbradham opened 3 years ago

danbradham commented 3 years ago

Hi thank you for creating tk-blender. I've set it up in our pipeline and run into a bit of an issue.

Describe the bug By setting BLENDER_USER_SCRIPTS to the tk-blender/scripts directory tk-blender essentially disables the default site for user addons and modules. I feel like this is problematic because it makes it difficult to share and install addons in a pipeline without shipping a custom tk-blender that embeds the addons.

To Reproduce Steps to reproduce the behavior:

  1. Put an addon in C:\Users\\AppData\Roaming\Blender Foundation\Blender\\scripts\addons
  2. Launch Blender through Shotgun Toolkit
  3. Addon is unavailable in Blender.

Expected behavior Addons installed to the standard user scripts directory should be available when launching through Shotgun Toolkit.

Possible Solution It may make more sense to copy the shotgun_menu.py module into the existing user scripts startup for the current user. This way it doesn't conflict with a studio's existing pipeline or a users customized scripts folder.

This might be somewhat trivial like:

  1. check if BLENDER_USER_SCRIPTS is set
  2. If set: copy shotgun_menu.py to BLENDER_USER_SCRIPTS/startup
  3. If not set: copy shotgun_menu.py to default BLENDER_USER_SCRIPTS/startup

The default locations can be found here https://docs.blender.org/manual/en/latest/advanced/blender_directory_layout.html

If this route was chosen, a small bit of logic would need to be added to the shotgunmenu.register to return quickly if Blender was not launched via Shotgun i.e. there is no SGTK* environment variable.