Inheritance |
|
You can’t instantiate this object directly, call hou.shelves.newTool instead.
Methods ¶
General ¶
destroy()
Deletes the tool from Houdini session and removes its definition from the file it’s stored in.
setData(script='', language=hou.scriptLanguage.Python, icon='', help='', help_url='', network_categories=(), viewer_categories=(), cop_viewer_categories=(), network_op_type='', viewer_op_type='', locations=())
Convenience method for setting multiple options at once, rather than
calling multiple set
methods.
Sets various options on the tool based on optional keyword arguments you pass.
# Get a tool t = shelves.tool("geometry_sphere") # Set the tool's icon and help URL t.setData(icon="SOP_sphere", help_url="tool:sphere")
Help and icon ¶
setHelp(help)
Sets the tool’s help text. Houdini will parse this as wiki text and display it in the help viewer when the user requests help for this tool. To have the help viewer go to a URL instead, use setHelpURL.
help()
→ str
Returns the tool’s help text.
setHelpURL(help_url)
Sets a URL the help viewer should go to when the user requests help for this tool.
If this is not empty, Hoduini will open this URL in the help viewer
instead of parsing and displaying the contents of Tool.help()
.
helpURL()
→ str
Returns the URL pointing to this tool’s help.
setIcon(icon)
Sets a new icon string for the tool. The string can contain a file path or
URL pointing to an SVG file or an image file Houdini knows how to load.
You can use an opdef:
path to refer to an icon file inside an asset.
icon()
→ str
Returns the tool’s icon string.
keywords()
→ Sequence[str]
Returns the keywords associated with this tool. You can set the keywords for a tool using setKeywords()
.
Currently the keywords are not used by Houdini, but may be useful for scripted user/studio tools.
setKeywords(keywords: Sequence[str])
The argument is a list or tuple of strings representing the keywords for this tool. Be careful not to pass a string because Python will interpret it as a list of single-character keywords. Houdini makes no effort to avoid duplicate keywords.
These strings correspond to the Keywords field in the tool editing window. Internally, the keywords are stored as a list of strings. But if a user edits the Keyword field in the UI, Houdini splits the text at commas to get the keyword list. This means you can get strange results if you use this method to store keywords that contain commas. The commas will be preserved until the user edits the keywords in the UI, then any commas within keywords will be re-interpreted as separators, and the list of keywords will change.
Script ¶
setScript(script)
Sets the text of the script to run when the user clicks the tool in the shelf. See how to write a tool script for information on the global variables available to the script and tips for common tasks.
script()
→ str
Returns the text of the script that runs when the user clicks the tool.
setLanguage(language)
Sets a new language for the script, where ‹language› is a value from the
hou.scriptLanguage module (usually hou.scriptLanguage.Python
).
t = shelves.tool("tool_1") t.setLanguage(hou.scriptLanguage.Hscript) t.setScript("message hello")
Note
We highly recommend writing scripts in Python rather than Hscript.
language()
→ hou.scriptLanguage enum value
Returns a value representing the language in which the tool script is written.
>>> t = shelves.tool("geometry_sphere") >>> t.language() == hou.scriptLanguage.Python True
Categorization ¶
setToolLocations(locations)
Sets the description of the places that the tool should show up in the UI. Eg, a tool could be configured to be included in the network pane’s TAB menu but not in the viewport pane’s TAB menu.
setToolMenuCategories(pane_type, categories)
Set the tool categories. The categories are used to further control the visibility of the tool. For example, some tools specify “Mantra” or “RenderMan” as keywords, and they show up in the TAB menu only if the specified renderer is configured as active in the preferences pane.
setToolMenuOpType(pane_type, op_type)
Sets the operator type to be associated with the tool. The tool will show up in the TAB menu only if the operator can be created. For example, some operator types are scoped only to a particular parent, thus the tool that creates nodes of this type makes sense only inside that parent.
toolMenuCategories(pane_type)
→ tuple of hou.NodeTypeCategory
Returns the categories specified for the tool.
toolMenuLocations()
→ tuple of str
Returns the submenus of the TAB menu in which the tool is included.
toolMenuOpType(pane_type)
→ str
Returns the operator type associated with this tool.
Methods from hou.ShelfElement ¶
setFilePath(file_path)
Sets the path string for where this object’s definition is stored.
filePath()
→ str
Returns the file that contains the definition of this object.
fileLocation()
→ str
Returns the file location description in a human readable format. For example, it is a file path for disk files, and information about an HDA if the element is stored in an HDA tool section.
setName(name)
Sets this object’s internal name. This is how you refer to the object in scripts.
The name has similar rules to naming Houdini nodes: it must not start with a number, and can only contain letters, numbers, an underscores.
For example, if a Tool objects name is foo
, you can get a reference
to it using:
footool = shelves.tool("foo")
name()
→ str
Returns the internal name of this object.
Multiple objects may have the same name (for example, two
different assets might both provide a hammer
tool), but only one will
be active at a time in a Houdini session.
setLabel(label)
Sets the object’s human-readable label. This is what’s displayed in the UI.
label()
→ str
Returns the object’s human-readable label.
setReadOnly(on)
# Get a reference to a tool t = hou.shelves.tool("geometry_sphere") # Prevent the tool from being modified t.setReadOnly(True) # Allow the tool to be modified t.setReadOnly(False)
isReadOnly()
→ bool
Returns True
if the element is read-only (can’t be edited).