tk-shotgun Documentation
Using Tank Actions
Developing Apps for Shotgun
Setup and Configuration

tk-shotgun Documentation

The Shotgun engine manages apps that can be launched from within Shotgun. Sometimes we refer to these Tank Apps as Tank Actions. They typically appear as items on menus inside of shotgun.

Using Tank Actions

Tank Actions are visible on the shotgun Home page:

Tank Actions

They can also be found on the standard Shotgun context menu, which can be shown by right clicking on an object or a selection:

Tank Actions

When you click on an action, processing will immediately start. Once the app has completed, a message is typically displayed with some status information, or an error message if things didn't work.

Developing Apps for Shotgun

Developing apps that run inside of Shotgun is easy! If you are not familiar with how app development works in general, head over to the Platform documentation and read the introductory material over there. In this section we will just cover the Shotgun specific aspects of the app development process!

A hello-world style Shotgun App would look something like this:

from tank.platform import Application

class LaunchPublish(Application):

    def init_app(self):
        """
        Register menu items with Shotgun
        """

        p = {
            "title": "Hello, World!",
            "entity_types": ["Version"],
            "deny_permissions": ["Artist"],
            "deny_platforms": ["Windows", "Mac", "Linux"],
            "supports_multiple_selection": False
        }

        self.engine.register_command("hello_world_cmd", self.do_stuff, p)

    def do_stuff(self, entity_type, entity_ids):
        # this message will be displayed to the user
        self.engine.log_info("Hello, World!")

We use the register_command method to add stuff to Shotgun's menus. You will need to supply the following parameters via the param dictionary:

The first parameter to the register_command method is a string which uniquely identifies this command. You may for example want to have different commands which appear to have the same name on the menu, but do different things, and then we cannot use the menu title to identify them. The following example illustrates this:

p_shot  = { "title": "Create Folders", "entity_types": ["Shot"] }
p_asset = { "title": "Create Folders", "entity_types": ["Asset"] }

self.engine.register_command("create_folders_shot", self.process_shot, p_shot)
self.engine.register_command("create_folders_asset", self.process_asset, p_asset)

The second parameter to the register_command method is a callback to the method that will do the actual work. This callback will be always passed the two parameters entity_type and entity_ids. If you would rather use a different set of parameters when calling your callback, either wrap it via a lambda or an explicit helper method.

Setup and Configuration

To see all the various configuration parameters that you can set in order to customize the behaviour of this item, please head over to the settings page.

tk-shotgun Documentation. This was auto generated on 2013-05-16. Click here for Release Notes.