On this page |
Overview ¶
The Handle
class lets you manipulate handles bound to viewer states.
Methods ¶
__init__(scene_viewer, name)
Creates an object for accessing a handle of a given name. hou.Handle is typically used with python viewer states.
Warning
Handle objects are typically created from a python viewer state constructor. However, calling
methods on Handle
objects must be done once the state has been entered, exceptions will be
raised otherwise.
scene_viewer
A hou.SceneViewer object referencing the scene viewer where the handle is going to be used. Exception is thrown if the scene viewer is not compatible.
name
A string to identify the handle object. The name corresponds to the handle’s name used at binding time. See hou.ViewerStateTemplate.bindHandle() or hou.ViewerStateTemplate.bindStaticHandle for details.
class MyState(object): def __init__(self, state_name, scene_viewer): self.state_name = state_name self.scene_viewer = scene_viewer self.handle = hou.Handle(scene_viewer, "Transform") # Create a template to describe the state and its bindings template = hou.ViewerStateTemplate("mystate", "My Custom State", hou.sopNodeTypeCategory()) template.bindFactory(MyState) template.bindHandle("xform", "Transform")
name()
: → string
The name of this handle.
show(value)
Shows or hides the handle.
value
Bool
value, True
to show the handle, False
to hide it.
type()
: → string
Returns the type name of the handle. The return value corresponds to the type used for binding the handle. See hou.ViewerStateTemplate.bindHandle() or hou.ViewerStateTemplate.bindStaticHandle for details.
update(immediate)
This method forces the handle to update. Useful if a change made to a viewer state requires one of its handle to get updated. For dynamic handles, this will trigger a call to the onStateToHandle
callback, allowing the viewer state to update the proper handle parameter(s).
immediate
Controls when the update is performed. If False, the update is delayed until Houdini is on idle. If True, the update is performed immediately. Defaults to False.
visible()
: → bool
Returns True
if the handle is visible, False
otherwise.
enableParms(parm_names)
Dynamically enables the parms of this handle specified with parm_names
. If handle_parms
is
empty (default), all handle parms are enabled.
Raises exception if the handle is not bound dynamically to a viewer state.
Note
Some handles like xform
may not display its components right away when enabled. This can
happen if the components were previously disabled. For instance, disabling the rotation (rx,ry,rz)
and re-enabling it again will not restore the previous rotate mode to display the rotation knobs.
Restoring the rotate mode must rather be achieved by cycling the Y
key or by calling
hou.Handle.applySetting.
See also hou.Handle.disableParms().
parm_names
A list of names specifying the handle parms to enable. parm_names
must contain the handle
parm names as described here. Exception is raised if
parm_names
contains unknown parm names.
disableParms(parm_names)
This method does the opposite of hou.Handle.enableParms() and dynamically disables the
handle parms specified in parm_names
. If handle_parms
is empty (default), all handle parms
are disabled.
Raises exception if the handle is not bound dynamically to a viewer state.
parm_names
A list of names specifying the handle parms to disable. parm_names
must contain the handle
parm names as described here. Exception is raised if
parm_names
contains unknown parm names.
applySettings(settings)
Apply one or more settings to this handle.
settings
A string containing the handle specific settings. Multiple settings must be space separated.