Skip to content

Commit

Permalink
Merge pull request #1 from AlexLaur/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
AlexLaur authored Apr 12, 2023
2 parents 957ee9d + e75874e commit de0f199
Show file tree
Hide file tree
Showing 33 changed files with 2,482 additions and 255 deletions.
100 changes: 12 additions & 88 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,95 +1,19 @@
[![Python 2.7 3.7](https://img.shields.io/badge/python-2.7%20%7C%203.7-blue.svg)](https://www.python.org/)
[![Build Status](https://dev.azure.com/shotgun-ecosystem/Toolkit/_apis/build/status/Apps/tk-multi-starterapp?branchName=master)](https://dev.azure.com/shotgun-ecosystem/Toolkit/_build/latest?definitionId=57&branchName=master)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Linting](https://img.shields.io/badge/PEP8%20by-Hound%20CI-a873d1.svg)](https://houndci.com)

# Welcome to the ShotGrid Pipeline Toolkit Starter App!
## Documentation
This repository is a part of the ShotGrid Pipeline Toolkit.

This app serves as a quick way to get started when doing Toolkit App development.
If you want to get up and running quickly, follow these simple steps:
- For more information about this app and for release notes, *see the wiki section*.
- For general information and documentation, click here: https://developer.shotgridsoftware.com/d587be80/?title=Integrations+User+Guide
- For information about ShotGrid in general, click here: https://help.autodesk.com/view/SGSUB/ENU/

## Step 1. Pick a branch!
## Using this app in your Setup
All the apps that are part of our standard app suite are pushed to our App Store.
This is where you typically go if you want to install an app into a project you are
working on. For an overview of all the Apps and Engines in the Toolkit App Store,
click here: https://developer.shotgridsoftware.com/162eaa4b/?title=Pipeline+Integration+Components.

This repo has got several branches, illustrating slightly different workflows:

- the `master` branch contains a standard multi app which runs in all engines.
- the `shotgun_multi_select` branch shows how to get started if you want to create
a *shotgun specific* app where you can select multiple objects in ShotGrid and
pass this selection into the app.
- the `shotgun_model_delegate` branch illustrates how to use the ShotGrid MVC model
for efficient data retrieval and the toolkit widget delegate system for display of content.

## Step 2. Fork this Repository!

First of all, fork this repo. You can fork it to your own github accout or fork it to
an internal git server, that's totally up to you! At this time, make sure you also
rename it to something sensible. We recommend the naming convention `tk-ENGINE-APPNAME`,
where ENGINE is set to `multi` if the app can run in more than one engine. For example,
if you are working on a rigging tool in maya, you may want to name it `tk-maya-characterposer`.

## Step 3. Install your forked App in Toolkit

### Create a Dev Area
Now, first things first - before starting development, let's install the App. First, create a
development sandbox for your project by going to the pipeline configurations page in ShotGrid
and click select "Clone" on the menu when right clicking on the primary pipeline configuration.
This will give you a private place to do development and you wont be disturbing the production.

### Install the new repository
With your development sandbox there will be a specific tank command that you can use to address
this particular configuration. Open a shell and navigate to your sandbox. Now run the install app
command. When you install an app, you need to choose an environment and an engine. The engine is
the application you will be running, so either `tk-maya`, `tk-nuke` etc. The environment is a
collection of tools that you want to run against a specific work area. In our default
configuration, when working with Shots, the environment is called `shot_step` and
when working with Assets, the environment is called `asset_step`.

```
> cd /your/development/sandbox
> ./tank install_app shot_step tk-maya user@remotehost:/path_to/tk-multi-mynewapp.git
```

This will find the latest git tag and install that into your setup. If you want more information
about how the install_app command works, just run it without any options.

Now, to test that the App was installed correctly, go to a Shot task in ShotGrid and launch maya
from your development sandbox. Toolkit now tracks this repository and if you create new tags,
these will be detected by Toolkit's update system.

## Step 4. Set up your local environment

Now clone your forked repo locally, so that you have the code on disk somewhere. Next, we need
to switch toolkit so that it doesn't track the latest tag in the git repo, but instead looks
at your local code. For example, if you have your locally checked out code in `/Users/john.smith/dev/tk-multi-mynewapp`,
you would do the following:

```
> cd /your/development/sandbox
> ./tank switch_app shot_step tk-maya tk-multi-mynewapp /Users/john.smith/dev/tk-multi-mynewapp
```

## Step 5. Make changes!

Make changes to your code. Since you are now running tookit with a dev setup, there is a reload
option on the menu. Clicking this will reload all apps and configuration, making it easy and
quick to iterate.

## Step 6. Tag up a version and switch back to git mode

When you are ready to release, tag up a version in git. Name it for example `v1.0.0`.
Then, switch back to git mode. Toolkit will pick up the tag with the higest number
and use that - your dev area is no longer used by the system.

```
> cd /your/development/sandbox
> ./tank switch_app shot_step tk-maya tk-multi-mynewapp user@remotehost:/path_to/tk-multi-mynewapp.git
```

## Step 7. Push your config changes to the production config

Lastly, push your configuration changes to the Primary production config for the project.

```
> cd /your/development/sandbox
> ./tank push_configuration
```
## Have a Question?
Don't hesitate to contact us! You can find us on https://knowledge.autodesk.com/contact-support
14 changes: 10 additions & 4 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
# not expressly granted therein are reserved by Shotgun Software Inc.


from sgtk.platform import Application
import sgtk


class StgkStarterApp(Application):
class MultiSupport(sgtk.platform.Application):
"""
The app entry point. This class is responsible for initializing and tearing down
the application, handle menu registration etc.
Expand All @@ -27,7 +27,7 @@ def init_app(self):
# that resides inside the python folder in the app. This is where the actual UI
# and business logic of the app is kept. By using the import_module command,
# toolkit's code reload mechanism will work properly.
app_payload = self.import_module("app")
app_payload = self.import_module("tk_multi_support")

# now register a *command*, which is normally a menu entry of some kind on a Shotgun
# menu (but it depends on the engine). The engine will manage this command and
Expand All @@ -38,4 +38,10 @@ def init_app(self):
menu_callback = lambda: app_payload.dialog.show_dialog(self)

# now register the command with the engine
self.engine.register_command("Show Starter Template App...", menu_callback)
self.engine.register_command("Report a problem...", menu_callback)

def destroy_app(self):
"""
Clean up app
"""
self.log_debug("Destroying tk-multi-support")
23 changes: 23 additions & 0 deletions hooks/custom_infos.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 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


HookClass = sgtk.get_hook_baseclass()


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
44 changes: 44 additions & 0 deletions hooks/scene_infos_tk-maya.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# 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 maya import cmds


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 cmds.file(query=True, sceneName=True)

def _get_dcc_name(self):
name = self.parent.engine.host_info.get("name")
if name == "unknown":
return "Maya"
return name

def _get_dcc_version(self):
version = self.parent.engine.host_info.get("version")
if version == "unknown":
return cmds.about(version=True)
return version
Loading

0 comments on commit de0f199

Please sign in to comment.