SUMMARY
This article covers editing/customizing 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 Q100401: How to create a Shelf Item in Katana to provide easily accessible custom Python scripts.
EDITING SHELF ITEMS
A shelf item can be edited after creation 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.
Docstrings of Shelf Item Scripts
If you have created the Shelf Item Script using the process described in Q100401: How to create a Shelf Item in Katana to provide easily accessible custom Python scripts, 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 is the name your Script Item displays in the Shelf Action
- ICON is the image location of your chosen icon. (Discussed further below)
- KEYBOARD_SHORTCUT is the shortcut your Script Item can be run with
- SCOPE is used to define specific node types that the shelf item applies to
- <description> is your help tooltip for the shelf item
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.
Editing the Shelf Item Script
To demonstrate how the above docstring can be utilized, copy the Shelf Item Script below into a blank .py file, and save it in a .katana/Shelves/Custom_Shelves/ directory:
""" 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.
For more information on putting together similar Python functions can be found in the Example Scripts Developer Guide.
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: $KATANA_HOME\bin\python\UI4\Resources\Icons
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. Katana's default resources search path is $KATANA_HOME\bin\python\UI4\Resources. For example:
ICON: Icons\Scenegraph\locator32.png
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
If you wish to remove a Shelf from the shelf actions, this can be done by deleting the shelf folder from your .katana\Shelves folder. If you had Katana open and want to see the changes or like the shelf to be removed from the drop-down shelf, click on Reload Shelf, and any changes made to the .katana/shelf files will be updated on your Katana scene.
NOTE: If you wish to rename the shelf, it can be done by locating your .katana/shelf file and then renaming the folder [Custom Folder].
REMOVING SHELF ITEMS
If you wish to remove a Shelf Item, this can be done by deleting the Python file containing the Shelf Item Script or using the Shelf Actions pop-up menu. To remove Self Items from within Katana:
Navigate to the Shelf Action menu and right click the shelf item you want to delete, then select 'Delete...'.
Once pressed, a pop-up window will ask you to confirm the deletion. Click Delete to remove the shelf item.
NOTE: As displayed in the above pop-up window, Katana will not delete the Shelf Item Script but instead will append the extension '.bak' so the script no longer loads 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 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.
FURTHER READING
For an overview of Shelves Item Scripts in Katana, please visit the Shelf Item Scripts User Guide.
If you are setting up a shelf item for the first time, please see Q100401: How to create a Shelf Item in Katana to provide easily accessible custom Python scripts.
We're sorry to hear that
Please tell us why