Q100402: Editing and removing Shelf Items in Katana
This article covers editing/customising a Shelf Item as well as the procedure to remove one if needed.
If you are looking to set up a Shelf Item for the first time, please follow the steps and information in this article: Q100401: Creating a Shelf Item in Katana
Editing a Shelf Items after creation can be done by accessing the Shelf Item Python script in Katana, or navigating to your .katana and the relevant Shelves, ShelvesNodeSpecific or ShelvesScenegraph directory, and locating the script there.
1. To access your script in Katana, open your Shelf Action, select the desired Shelf Item and right click 'View Source':
This will open the Shelf Item Python script in a text editor like:
2. To access your script outside of Katana, navigate to your .katana/Shelves, .katana/ShelvesNodeSpecific or .katana/ShelvesScenegraph folder, and locate the relevant .py file.
This will be in a sub-folder of one of those directories, named after your Shelf Item. From there you can open the file in the desired Python editor.
If you have created the Shelf Item Script using the process described in this article: Q100401: Creating a Shelf Item in Katana, it will contain a docstring by default that looks like:
""" NAME: <the name of the script to show in the UI> ICON: <the filename of icon to use in the UI>
KEYBOARD_SHORTCUT: <the keyboard shortcut to use in the UI to run the Shelf Item Script> SCOPE: <names of types of nodes to target by node-specific shelf items> <description> """
This holds the information about your script as detailed below:
- NAME will be the name your Script Item displays in the Shelf Action
- ICON will be the image location of your chosen icon. (Discussed further below)
- KEYBOARD_SHORTCUT will be the shortcut your Script Item can be run with
NOTE: In Katana versions prior to 2.6v2 you may see DROP_TYPES in the Shelf Item Script file. This is a legacy option and has been replaced with KEYBOARD_SHORTCUT.
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 here: Katana Online Help - Keyboard Shortcuts
- SCOPE will be used to define specific node types that the Shelf Item applies to
- <description> will be your help tooltip for the Shelf Item
Editing Shelf Items after creation
To demonstrate how the above docstring can be utilised, copy the Shelf Item Script below into a blank .py file, and save it in a .katana/Shelves/Custom_Shelves/ directory:
NOTE: Create the folder path within .katana if it does not exist.
""" NAME: Float Selected ICON: Icons\Scenegraph\locator32.png KEYBOARD_SHORTCUT: T SCOPE: none Float Selected Nodes via Keyboard Shortcut """ # Get list of selected nodes nodeList = NodegraphAPI.GetAllSelectedNodes() # Find Nodegraph tab and float nodes nodegraphTab = UI4.App.Tabs.FindTopTab('Node Graph') if nodegraphTab: nodegraphTab.floatNodes(nodeList)
After you have saved the script, reload the Shelf via 'Add -> Reload Shelf' within the Katana Shelf Action menu.
Your Shelf Item should display as 'Float Selected' with a custom keyboard shortcut, icon and help tooltip:
The Shelf Item Script functionality is to float any currently selected nodes, when triggered with the keyboard shortcut (T) or by selecting the Shelf Item from the Shelf Action menu.
Floated nodes will follow your cursor until you left-click to let go, which saves having to click and drag the selected nodes or backdrops manually.
More information on putting together similar Python functions can be found in the Katana Developer Guide here: Katana Developers Guide - Example Scripts
Choosing your Shelf Item icon
To replace the icon of your Shelf Item displayed in the Shelf Action menu, you can choose one of Katana's default icons from the following location:
To use an icon from the ones available in Katana for your Shelf Item, you need to specify the path to the icon after Katana's default resources search path.
where Katana's default resources search path is:
NOTE: If you would like to use other custom icons, you need to add the full icon path to the ICON: section of the Python script.
Removing Shelf Items
If you wish to remove a Shelf Item this can be done by:
- removing the Python file containing the Shelf Item Script
- navigating to the Shelf Action menu and right clicking the Shelf Item you want to delete, then selecting 'Delete...':
Once pressed, a pop-up window will ask you to confirm the deletion. Clicking Delete will remove the Shelf Item.
NOTE: As displayed in the above pop-up window, Katana will not delete the Shelf Item Script but instead will add the extension .bak at the end so that it no longer loads and displays in Katana.
It will be saved as a backup file, to be restored if needed.
If you wish to add it back to your Shelf, navigate to its location and remove the '.bak' extension and the Shelf Item Script will be loaded and become usable.
NOTE: After removing .bak, go to Shelf Action and use 'Add->Reload...' so that Katana reloads all available Shelf Items for display in your session.
If you are setting up a Shelf Item for the first time, please see the following article: Q100401: Creating a Shelf Item in Katana
More information on Shelf Item Scripts can be found in our Katana online help here: Katana Online Help - Shelf Scripts
We're sorry to hear that!Please tell us why.