From e75874eedf07e0c8ca7ab93fdd104f795d0cdb83 Mon Sep 17 00:00:00 2001 From: Alexandre LAURETTE Date: Wed, 12 Apr 2023 10:10:06 +0200 Subject: [PATCH] add hooks for other DCCs --- hooks/custom_infos.py | 1 + hooks/scene_infos_tk-3dsmaxplus.py | 45 ++++++++++++++++++ hooks/scene_infos_tk-hiero.py | 67 +++++++++++++++++++++++++++ hooks/scene_infos_tk-houdini.py | 42 +++++++++++++++++ hooks/scene_infos_tk-motionbuilder.py | 43 +++++++++++++++++ hooks/scene_infos_tk-nuke.py | 43 +++++++++++++++++ hooks/scene_infos_tk-shell.py | 42 +++++++++++++++++ 7 files changed, 283 insertions(+) create mode 100644 hooks/scene_infos_tk-3dsmaxplus.py create mode 100644 hooks/scene_infos_tk-hiero.py create mode 100644 hooks/scene_infos_tk-houdini.py create mode 100644 hooks/scene_infos_tk-motionbuilder.py create mode 100644 hooks/scene_infos_tk-nuke.py create mode 100644 hooks/scene_infos_tk-shell.py diff --git a/hooks/custom_infos.py b/hooks/custom_infos.py index dbc576f..436643a 100644 --- a/hooks/custom_infos.py +++ b/hooks/custom_infos.py @@ -18,5 +18,6 @@ class CustomInfos(HookClass): """Add custom informations to the report. This hook is called during the generation of the report. """ + def collect(self, report): return report diff --git a/hooks/scene_infos_tk-3dsmaxplus.py b/hooks/scene_infos_tk-3dsmaxplus.py new file mode 100644 index 0000000..6866575 --- /dev/null +++ b/hooks/scene_infos_tk-3dsmaxplus.py @@ -0,0 +1,45 @@ +# Copyright (c) 2015 Shotgun Software Inc. +# +# CONFIDENTIAL AND PROPRIETARY +# +# This work is provided "AS IS" and subject to the Shotgun Pipeline Toolkit +# Source Code License included in this distribution package. See LICENSE. +# By accessing, using, copying or modifying this work you indicate your +# agreement to the Shotgun Pipeline Toolkit Source Code License. All rights +# not expressly granted therein are reserved by Shotgun Software Inc. + +import sgtk + +import MaxPlus + + +HookClass = sgtk.get_hook_baseclass() + + +class SceneInfos(HookClass): + + """Scene informations. It collects all informations like the current scene, + the DCC name and the DCC version. + """ + + def collect(self, scene_infos): + scene_infos.current_scene = self._get_scene_path() + scene_infos.dcc_name = self._get_dcc_name() + scene_infos.dcc_version = self._get_dcc_version() + return scene_infos + + def _get_scene_path(self): + file_path = MaxPlus.FileManager.GetFileNameAndPath() + if not file_path: + return "" + return file_path + + def _get_dcc_name(self): + name = self.parent.engine.host_info.get("name") + if name == "unknown": + return "3dsMaxPlus" + return name + + def _get_dcc_version(self): + version = self.parent.engine.host_info.get("version") + return version diff --git a/hooks/scene_infos_tk-hiero.py b/hooks/scene_infos_tk-hiero.py new file mode 100644 index 0000000..bf46db0 --- /dev/null +++ b/hooks/scene_infos_tk-hiero.py @@ -0,0 +1,67 @@ +# Copyright (c) 2015 Shotgun Software Inc. +# +# CONFIDENTIAL AND PROPRIETARY +# +# This work is provided "AS IS" and subject to the Shotgun Pipeline Toolkit +# Source Code License included in this distribution package. See LICENSE. +# By accessing, using, copying or modifying this work you indicate your +# agreement to the Shotgun Pipeline Toolkit Source Code License. All rights +# not expressly granted therein are reserved by Shotgun Software Inc. + +import os +import sgtk + +import hiero.core + +from sgtk import TankError + + +HookClass = sgtk.get_hook_baseclass() + + +class SceneInfos(HookClass): + + """Scene informations. It collects all informations like the current scene, + the DCC name and the DCC version. + """ + + def collect(self, scene_infos): + scene_infos.current_scene = self._get_scene_path() + scene_infos.dcc_name = self._get_dcc_name() + scene_infos.dcc_version = self._get_dcc_version() + return scene_infos + + def _get_scene_path(self): + project = self._get_current_project() + return project.path().replace("/", os.path.sep) + + def _get_dcc_name(self): + name = self.parent.engine.host_info.get("name") + if name == "unknown": + return "Hiero" + return name + + def _get_dcc_version(self): + version = self.parent.engine.host_info.get("version") + return version + + def _get_current_project(self): + """ + Returns the current project based on where in the UI the user clicked + """ + + # get the menu selection from hiero engine + selection = self.parent.engine.get_menu_selection() + + if len(selection) != 1: + raise TankError("Please select a single Project!") + + if not isinstance(selection[0], hiero.core.Bin): + raise TankError("Please select a Hiero Project!") + + project = selection[0].project() + if project is None: + # apparently bins can be without projects (child bins I think) + raise TankError("Please select a Hiero Project!") + + return project diff --git a/hooks/scene_infos_tk-houdini.py b/hooks/scene_infos_tk-houdini.py new file mode 100644 index 0000000..520c306 --- /dev/null +++ b/hooks/scene_infos_tk-houdini.py @@ -0,0 +1,42 @@ +# Copyright (c) 2015 Shotgun Software Inc. +# +# CONFIDENTIAL AND PROPRIETARY +# +# This work is provided "AS IS" and subject to the Shotgun Pipeline Toolkit +# Source Code License included in this distribution package. See LICENSE. +# By accessing, using, copying or modifying this work you indicate your +# agreement to the Shotgun Pipeline Toolkit Source Code License. All rights +# not expressly granted therein are reserved by Shotgun Software Inc. + +import sgtk + +import hou + + +HookClass = sgtk.get_hook_baseclass() + + +class SceneInfos(HookClass): + + """Scene informations. It collects all informations like the current scene, + the DCC name and the DCC version. + """ + + def collect(self, scene_infos): + scene_infos.current_scene = self._get_scene_path() + scene_infos.dcc_name = self._get_dcc_name() + scene_infos.dcc_version = self._get_dcc_version() + return scene_infos + + def _get_scene_path(self): + return str(hou.hipFile.name()) + + def _get_dcc_name(self): + name = self.parent.engine.host_info.get("name") + if name == "unknown": + return "Houdini" + return name + + def _get_dcc_version(self): + version = self.parent.engine.host_info.get("version") + return version diff --git a/hooks/scene_infos_tk-motionbuilder.py b/hooks/scene_infos_tk-motionbuilder.py new file mode 100644 index 0000000..15db4ea --- /dev/null +++ b/hooks/scene_infos_tk-motionbuilder.py @@ -0,0 +1,43 @@ +# Copyright (c) 2015 Shotgun Software Inc. +# +# CONFIDENTIAL AND PROPRIETARY +# +# This work is provided "AS IS" and subject to the Shotgun Pipeline Toolkit +# Source Code License included in this distribution package. See LICENSE. +# By accessing, using, copying or modifying this work you indicate your +# agreement to the Shotgun Pipeline Toolkit Source Code License. All rights +# not expressly granted therein are reserved by Shotgun Software Inc. + +import sgtk + +from pyfbsdk import FBApplication + + +HookClass = sgtk.get_hook_baseclass() + + +class SceneInfos(HookClass): + + """Scene informations. It collects all informations like the current scene, + the DCC name and the DCC version. + """ + + def collect(self, scene_infos): + scene_infos.current_scene = self._get_scene_path() + scene_infos.dcc_name = self._get_dcc_name() + scene_infos.dcc_version = self._get_dcc_version() + return scene_infos + + def _get_scene_path(self): + fb_app = FBApplication() + return fb_app.FBXFileName + + def _get_dcc_name(self): + name = self.parent.engine.host_info.get("name") + if name == "unknown": + return "MotionBuilder" + return name + + def _get_dcc_version(self): + version = self.parent.engine.host_info.get("version") + return version diff --git a/hooks/scene_infos_tk-nuke.py b/hooks/scene_infos_tk-nuke.py new file mode 100644 index 0000000..089d570 --- /dev/null +++ b/hooks/scene_infos_tk-nuke.py @@ -0,0 +1,43 @@ +# Copyright (c) 2015 Shotgun Software Inc. +# +# CONFIDENTIAL AND PROPRIETARY +# +# This work is provided "AS IS" and subject to the Shotgun Pipeline Toolkit +# Source Code License included in this distribution package. See LICENSE. +# By accessing, using, copying or modifying this work you indicate your +# agreement to the Shotgun Pipeline Toolkit Source Code License. All rights +# not expressly granted therein are reserved by Shotgun Software Inc. + +import os +import sgtk + +import nuke + + +HookClass = sgtk.get_hook_baseclass() + + +class SceneInfos(HookClass): + + """Scene informations. It collects all informations like the current scene, + the DCC name and the DCC version. + """ + + def collect(self, scene_infos): + scene_infos.current_scene = self._get_scene_path() + scene_infos.dcc_name = self._get_dcc_name() + scene_infos.dcc_version = self._get_dcc_version() + return scene_infos + + def _get_scene_path(self): + return nuke.root().name().replace("/", os.path.sep) + + def _get_dcc_name(self): + name = self.parent.engine.host_info.get("name") + if name == "unknown": + return "Nuke" + return name + + def _get_dcc_version(self): + version = self.parent.engine.host_info.get("version") + return version diff --git a/hooks/scene_infos_tk-shell.py b/hooks/scene_infos_tk-shell.py new file mode 100644 index 0000000..cc77d67 --- /dev/null +++ b/hooks/scene_infos_tk-shell.py @@ -0,0 +1,42 @@ +# Copyright (c) 2015 Shotgun Software Inc. +# +# CONFIDENTIAL AND PROPRIETARY +# +# This work is provided "AS IS" and subject to the Shotgun Pipeline Toolkit +# Source Code License included in this distribution package. See LICENSE. +# By accessing, using, copying or modifying this work you indicate your +# agreement to the Shotgun Pipeline Toolkit Source Code License. All rights +# not expressly granted therein are reserved by Shotgun Software Inc. + +import os + +import sgtk + + +HookClass = sgtk.get_hook_baseclass() + + +class SceneInfos(HookClass): + + """Scene informations. It collects all informations like the current scene, + the DCC name and the DCC version. + """ + + def collect(self, scene_infos): + scene_infos.current_scene = self._get_scene_path() + scene_infos.dcc_name = self._get_dcc_name() + scene_infos.dcc_version = self._get_dcc_version() + return scene_infos + + def _get_scene_path(self): + return os.getcwd() + + def _get_dcc_name(self): + name = self.parent.engine.host_info.get("name") + if name == "unknown": + return "tk-shell" + return name + + def _get_dcc_version(self): + version = self.parent.engine.host_info.get("version") + return version