Skip to content

Instantly share code, notes, and snippets.

@bohdon
Created July 11, 2022 14:58
Show Gist options
  • Save bohdon/c1e76c5e99cc43292072489999d55a9d to your computer and use it in GitHub Desktop.
Save bohdon/c1e76c5e99cc43292072489999d55a9d to your computer and use it in GitHub Desktop.
Bootstraps ShotGrid in Maya from a standalone launch.
import sys
# assumes a specific tk-core version is installed, other tk-core acquisition methods are available
tk_core_path = "C:/Program Files/Shotgun/Resources/Desktop/Python/bundle_cache/app_store/tk-core/v0.20.12/python"
# the project id to use for the context
project_id = 369
sys.path.append(tk_core_path)
import sgtk
# set authenticated user, requires a user to log in or be logged into ShotGrid desktop app
auth = sgtk.authentication.ShotgunAuthenticator()
user = auth.get_user()
sgtk.set_authenticated_user(user)
# create a boostrap manager, using same plugin_id that's used when Maya is launched from desktop app
mgr = sgtk.bootstrap.ToolkitManager(user)
mgr.plugin_id = 'basic.desktop'
project = {'type': 'Project', 'id': project_id}
# start tk-maya engine
engine = mgr.bootstrap_engine('tk-maya', entity=project)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment