python.tk_houdini.base_hooks.node_handler_base

Implicit, base hook class for all node handlers.

Module Contents

Classes

NodeHandlerBase

Common base class for all node handlers.

HookBaseClass[source]
class NodeHandlerBase[source]

Bases: HookBaseClass

Common base class for all node handlers.

NODE_CATEGORY[source]
NODE_TYPE[source]
SGTK_ALL_VERSIONS = sgtk_all_versions[source]
SGTK_FOLDER = sgtk_folder[source]
SGTK_IDENTIFIER = sgtk_identifier[source]
SGTK_REFRESH_VERSIONS = sgtk_refresh_versions[source]
SGTK_RESOLVED_VERSION = sgtk_resolved_version[source]
SGTK_VERSION = sgtk_version[source]
USE_SGTK = use_sgtk[source]
VERSION_POLICIES = [][source]
_create_sgtk_folder(self, node, use_sgtk_default=True, hou=None)[source]

Create the sgtk folder template.

This contains the common parameters used by all node handlers.

Parameters
  • node – A hou.Node instance.

  • use_sgtk_default (bool) – Whether the “Use Shotgun” checkbox is to be checked by default.

  • hou – The houdini module. We have to lazy load the houdini python module here, but not in the hooks, so use hook’s imports and pass it for efficiency.

_create_sgtk_parm_fields(self, node, hou=None)[source]

Create the sgtk folder template.

This contains the common parameters used by all node handlers.

Parameters
  • node – A hou.Node instance.

  • use_sgtk_default (bool) – Whether the “Use Shotgun” checkbox is to be checked by default.

  • hou – The houdini module. We have to lazy load the houdini python module here, but not in the hooks, so use hook’s imports and pass it for efficiency.

_create_sgtk_parms(self, node)[source]

Create the parameters that are going to live within the sgtk folder.

Parameters

node – A hou.Node instance.

Return type

list(hou.ParmTemplate)

abstract _customise_parameter_group(self, node, parameter_group, sgtk_folder)[source]

Here is where you define where the sgtk folder is to be placed, but also any other parameters that you wish to add to the node.

Parameters
  • node – A hou.Node instance.

  • parameter_group – The node’s ParmGroup.

  • sgtk_folder – A hou.ParmFolderTemplate containing sgtk parameters.

_enable_sgtk(self, node, sgtk_enabled)[source]

Enable/disable the sgtk parameters.

Parameters
  • node – A hou.Node instance.

  • sgtk_enabled (bool) – The state to set the parameters to.

_get_all_versions(self, node)[source]

Retrieve all the versions stored on the node.

Parameters

node – A hou.Node instance.

Return type

list(int)

_get_parameter_group(self, node)[source]

Get the given node’s parameter group.

Parameters

node – A hou.Node instance.

Return type

ParmGroup or None.

_get_template(self, template_name)[source]

Get a shotgun template from the given name.

Parameters

template_name (str) – The name of the template to get.

Return type

An sgtk.Template instance.

Raises

sgtk.TankError if no template name supplied or the template doesn’t exist.

_populate_versions(self, node)[source]

Get the versions in a format to populate the “sgtk_all_versions” parameter on the node.

Parameters

node – A hou.Node instance.

Returns

list(str), for example ‘[“1”, “1”, “2”, “2”, “3”, “3”]’

_refresh_file_path(self, node)[source]

Refresh the file paths generated by the node handler.

Parameters

node – A hou.Node instance.

abstract _remove_sgtk_items_from_parm_group(self, parameter_group)[source]

Remove all sgtk parameters from the node’s parameter template group.

Parameters

parameter_group (ParmGroup) – The parameter group containing sgtk parameters.

_resolve_all_versions_from_fields(self, fields, template)[source]

Using fields and a shotgun template, get all the versions on disk that relate to the current item.

Parameters
Return type

list(int)

abstract _restore_sgtk_parms(self, node)[source]

Restore any removed sgtk parameters onto the given node.

Parameters

node – A hou.Node instance containing sgtk parameters.

_set_up_init_node_values(self, node)[source]

From the settings init_node_values, populate this node.

Parameters

node – A hou.Node instance.

_set_up_node(self, node, parameter_group, hou=None)[source]

Set up a node for use with shotgun pipeline.

Parameters
  • node – A hou.Node instance.

  • parameter_group – A ParmGroup instance.

  • hou – The houdini module. We have to lazy load the houdini python module here, but not in the hooks, so use hook’s imports and pass it for efficiency.

_set_up_parms(self, node)[source]

Set up the given node’s parameters.

Parameters

node – A hou.Node instance.

activate_sgtk(self, node)[source]

Activate Shotgun parameters and callbacks if not already.

Commonly used by tk-multi-loader2 hooks.

Parameters

node – A hou.Node instance.

add_sgtk_parms(self, node)[source]

Add sgtk parameters to the given node.

Parameters

node – A hou.Node instance.

after_last_delete(self, node=None)[source]

Method to run on houdini’s AfterLastDelete callback.

Parameters

node – A hou.Node instance.

before_first_create(self, node=None)[source]

Method to run on houdini’s BeforeFirstCreated callback.

Parameters

node – A hou.Node instance.

enable_sgtk(self, kwargs)[source]

Callback to enable/disable the sgtk parameters.

static generate_callback_script_str(method_name)[source]

Helper function to generate a callback script string for houdini parameters.

Parameters

method_name (str) – The name of the method we want to be our callback.

Return type

str

get_publish_template(self, node)[source]

Get the shotgun publish template for this node handler.

Parameters

node – A hou.Node instance.

Return type

An sgtk.Template instance.

get_work_template(self, node)[source]

Get the shotgun work template for this node handler.

Parameters

node – A hou.Node instance.

Return type

An sgtk.Template instance.

classmethod gracefully_error(cls, *args, **kwargs)[source]

Publicly expose the gracefully_error_hook_method() decorator.

To be used in sub-classes by any of the following ways:

# Default error message, return None upon fail
@HookBaseClass.gracefully_error
@HookBaseClass.gracefully_error()

# Custom error message, return None upon fail
@HookBaseClass.gracefully_error("boo hoo")
@HookBaseClass.gracefully_error(message="boo hoo")

# Default error message, return 123 upon fail
@HookBaseClass.gracefully_error(default_return=123)

# Custom error message, return 123 upon fail
@HookBaseClass.gracefully_error("message", 123)
@HookBaseClass.gracefully_error(message="message", default_return=123)
on_created(self, node=None)[source]

Method to run on houdini’s OnCreated callback.

Parameters

node – A hou.Node instance.

on_deleted(self, node=None)[source]

Method to run on houdini’s OnDeleted callback.

Parameters

node – A hou.Node instance.

on_input_changed(self, node=None)[source]

Method to run on houdini’s OnInputChanged callback.

Parameters

node – A hou.Node instance.

on_loaded(self, node)[source]

Method to run on houdini’s OnLoaded callback.

Only refresh/register callback for when node is picked if Houdini has UI. Else don’t update export paths i.e. no UI when on farm.

Parameters

node (hou.Node) – Node just loaded into scene upon file open.

on_name_changed(self, node=None)[source]

Method to run on houdini’s OnNameChanged callback.

Parameters

node – A hou.Node instance.

on_node_event(self, event_type, **kwargs)[source]

Callback to handle individual node’s events.

Parameters
  • event_type (hou.nodeEventType) – Houdini node event triggered.

  • kwargs (dict[str]) – Various keyworded arguments for event triggered

on_updated(self, node=None)[source]

Method to run on houdini’s OnUpdated callback.

Parameters

node – A hou.Node instance.

populate_versions(self, kwargs)[source]

Callback to get the versions in a format to populate the “sgtk_all_versions” parameter on the node.

Returns

list(str), for example ‘[“1”, “1”, “2”, “2”, “3”, “3”]’

refresh_file_path(self, kwargs)[source]

Callback to refresh the file paths generated by the node handler.

refresh_file_path_from_version(self, kwargs)[source]

Callback to refresh the file paths generated by the node handler when the version is updated.

remove_sgtk_parms(self, node)[source]

Remove all sgtk parameters from the node’s parameter template group.

Parameters

node – A hou.Node instance containing sgtk parameters.

Returns

Whether Shotgun parameters were removed from node.

Return type

bool

restore_sgtk_parms(self, node)[source]

Restore any removed sgtk parameters onto the given node.

Parameters

node – A hou.Node instance containing sgtk parameters.

set_using_sgtk(self, node, enable)[source]

Enable/disable “Using Shotgun” for a node.

Logs a warning if “Using Shotgun” parameter doesn’t exist.

Parameters
  • node (hou.Node) – Node to enable/disable

  • enable (bool) – Whether “Using Shotgun” should be checked.

using_sgtk(self, node)[source]

Whether the node has “Using Shotgun” checked.

Parameters

node (hou.Node) – Node to check

Returns

If “Using Shotgun” is checked if parameter exists, else False.

Return type

bool