Q100401: How to create a Shelf Item in Katana to provide easily accessible custom Python scripts

Follow

SUMMARY

Shelf Item Scripts are Python scripts contained in shelf items grouped under Shelves, which can be executed from Katana's UI.

Shelves can be incredibly useful as they allow users to create tools that save time by launching Python operations from the shelf or via custom keyboard shortcuts.

Shelf Item Scripts can use Katana's APIs, like the NodegraphAPI to access various parts of Katana that can be queried or modified.

This article will further explain the shelf tool, as well as provide a short tutorial on setting up your first shelf item.

If you have already setup your first shelf item and would like tips to update or remove it, please see Q100402: How to edit and remove shelf items in Katana to modify existing custom Python scripts.

 

SHELF LOCATIONS

Shelf items are collated into pop-up UIs named Shelf Actions (cog gear16.png icon). The Shelf Action can be used for more broad functions, or created for the scene graph or specific nodes, as displayed below:

  • The main Shelf location, available via the main menu toolbar

       shelf_mainToolBar.png

  • Shelf location specifically for the Scene Graph tab

        shelf_SceneGraphTab.png

  • Widgets toolbar within nodes, which is available via the Parameters tab

        shelf_ParametersTab.png

To find out more about the different types of Shelves and how to set up Shelf Item Scripts for specific locations, please refer to the Shelf Item Scripts User Guide.

 

CREATING A SHELF ITEM SCRIPT

When setting up your first Shelf Item Script, there are several steps involved:

1. To start, open Katana and select the Shelf Action(cog gear16.png icon) on the main toolbar. 

2. At the top right of the UI, select 'Add -> New Shelf...', this will create a custom Shelf for your scripts.

NewShelf1.PNG

NewShelf.PNG

Enter the new Shelf name and click OK.

3. Go back to the Shelf Action cog icon, select your newly created Shelf and add your first shelf item with 'Add -> New Item...'

selectNewShelf.png

NewItem.png

A pop-up window will appear where you can name your shelf item and give it a keyboard shortcut if desired. Then select OK:

NewShelfScript.PNG

NOTE: When setting a keyboard shortcut for your custom shelf item, you won't be able to use a shortcut that already exists in Katana. A warning should be displayed, and the list of Katana default keyboard shortcuts can be found in the Keyboard Shortcuts Resources.

4. After initializing the creation, a text document will open with your Shelf Item Python Script file.ShelfScript_NotePad.PNG

 This will print 'hello, world' to your Katana terminal window by default.

NOTE: Using NodegraphAPI commands, you can add additional functionality for your Python script.

5. Run the Shelf Item Script either from the main Shelf Action, by selecting your new Shelf and clicking on your new shelf item, or by using the keyboard shortcut added earlier.

RunShelf.PNG

This will print 'hello, world' to your Katana terminal window.

 

FURTHER READING

For an overview of Shelves Item Scripts in Katana, please visit the Shelf Item Scripts User Guide.

To improve your shelf item by adding custom Python functions and editing the docstring to include custom icons or keyboard shortcuts, please read Q100402: How to edit and remove shelf items in Katana to modify existing custom Python scripts.

To see an example of a Shelf Item Script used to rename input/output ports, please read Q100372: How to rename input and output ports with Python for clearer connections

    We're sorry to hear that

    Please tell us why