-
Notifications
You must be signed in to change notification settings - Fork 46
Documentation
The Shotgun engine for Nuke contains a standard platform for integrating Shotgun Apps into Nuke. It is light weight and straight forward and adds a bunch of new things to Nuke.
It creates a Shotgun Menu in Nuke on which various items are displayed:
![Tank Menu](images/menu.png)It creates a Shotgun Node Menu in Nuke on which various items are displayed:
![Tank Menu](images/nodes_menu.png)It adds Shotgun shortcuts to the file dialogs which makes it easy to jump to various file system locations:
![Tank Menu](images/favourites.png)You can add your own shortcuts based on template paths in your current environment with the favourite_directories
setting. The "Shotgun Current Project" favourite is added automatically for each root defined. You can customize the name with the project_favourite_name
setting, or disable these favourites by setting the value to an empty string ''
Note: There is currently a bug in Nuke 8.0 running specifically on CentOS 6.5 that causes Nuke to crash when running Toolkit. Other versions of CentOS are unaffected. The Foundry is aware of this issue (bug 43766). If you are running into this, please contact us so we can try and help you workaround it until it is resolved in a future update of Nuke.
The Shotgun engine for Nuke will switch context automatically when files are loaded. Whenever a file is loaded, the engine will look at the file, try and resolve a context from it.
The Shotgun engine for Nuke makes it easy to handle custom gizmos. If you are writing an app which uses custom gizmos, you can just drop them into a folder called gizmos and the engine will automatically add that location to the nuke path:
![Nuke Gizmos](images/gizmo.png)You can then easily access your gizmo via the create node functionality:
nuke.createNode("WriteTank")
Warning!! Please note that while the use of gizmos may be convenient, it is typically NOT the right solution if you want to create nodes that persist in a scene. The reason for this is because as soon as you have put a gizmo in the scene, you have introduced a dependency between that scene and the gizmo code. Not only will you need to load the Shotgun Toolkit every time you load the scene, but you also need to carefully manage your code so that any updates to the code does not break old gizmos being used in scenes.
Apps that create custom nuke nodes need to be carefully crafted. We recommend not using gizmos since these require a dependency between the scene and the gizmo code. Instead, save your custom nodes as a nuke file and import them into the scene:
group_node_script = os.path.join(self.disk_location, "resources", "my_group_node.nk")
group_node = nuke.nodePaste(group_node_script)
Any code calling the node from within the app can just use the instance returned.
Any code needing to call the app from inside the group should do so carefully so that the code is backwards compatible. We recommend the following approach:
At app startup, register app handle as part of the nuke namespace:
def init_app(self):
nuke.tk_nuke_nameofmyapp = self
If you for example have a button on your group node and want to call some Shotgun app code, try to gracefully fail if the Shotgun Toolkit cannot be found. The below code is code that is associated with a python button knob that belongs to the group node that the app can create:
# have to gracefully support the case when
# sgtk is not in the system at all!
import nuke
try:
app = nuke.tk_nuke_nameofmyapp
app.do_something_v1(nuke.thisNode())
except:
nuke.warning("Could not do XYZ! Most likely Sgtk is not currently active.")
If you make changes to the app behaviour, just keep versioning up the version number on the app callback and that way your app code can support both the new and the old behaviour.