Skip to content

Commit

Permalink
add hooks for other DCCs
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandre LAURETTE committed Apr 12, 2023
1 parent bfbdc02 commit e75874e
Show file tree
Hide file tree
Showing 7 changed files with 283 additions and 0 deletions.
1 change: 1 addition & 0 deletions hooks/custom_infos.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
45 changes: 45 additions & 0 deletions hooks/scene_infos_tk-3dsmaxplus.py
Original file line number Diff line number Diff line change
@@ -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
67 changes: 67 additions & 0 deletions hooks/scene_infos_tk-hiero.py
Original file line number Diff line number Diff line change
@@ -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
42 changes: 42 additions & 0 deletions hooks/scene_infos_tk-houdini.py
Original file line number Diff line number Diff line change
@@ -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
43 changes: 43 additions & 0 deletions hooks/scene_infos_tk-motionbuilder.py
Original file line number Diff line number Diff line change
@@ -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
43 changes: 43 additions & 0 deletions hooks/scene_infos_tk-nuke.py
Original file line number Diff line number Diff line change
@@ -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
42 changes: 42 additions & 0 deletions hooks/scene_infos_tk-shell.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit e75874e

Please sign in to comment.