base_import_handler

Base Hook for other Houdini import node handlers.

These include:

  • alembic_import_handler

  • file_handler

  • image_handler

Module Contents

Classes

ImportNodeHandler

Base class for all import node handlers.

HookBaseClass[source]
class ImportNodeHandler[source]

Bases: HookBaseClass

Base class for all import node handlers.

ACCEPTS_MULTI_SELECTION = False[source]
DEFAULT_FILE_DATA[source]
DEFAULT_WORK_FILE_DATA[source]
FILECHOOSER_PATTERN = *[source]
HOU_FILE_TYPE[source]
INPUT_PARM[source]
LATEST_COMPLETE_POLICY = <LATEST COMPLETE>[source]
LATEST_POLICY = <LATEST>[source]
NODE_CATEGORY = Sop[source]
NODE_TYPE = alembic[source]
NOTHING_ON_DISK = Nothing on disk[source]
NO_FILE = No file selected[source]
NO_NODE = No node selected[source]
NO_PUBLISH = No publish selected[source]
NO_VERSIONS = No version[source]
SEQUENCE_REGEX = -9999[source]
SGTK_BROWSE = sgtk_browse[source]
SGTK_CURRENT_TAB = sgtk_current_tab[source]
SGTK_FILE_DATA = sgtk_file_data[source]
SGTK_FILE_PATH = sgtk_file_path[source]
SGTK_FILE_REFRESH_VERSIONS = sgtk_file_refresh_versions[source]
SGTK_FILE_RESOLVED_VERSION = sgtk_file_resolved_version[source]
SGTK_FILE_VERSION = sgtk_file_version[source]
SGTK_ID = sgtk_id[source]
SGTK_LAST_USED = sgtk_last_used[source]
SGTK_NAME = sgtk_name[source]
SGTK_NODE_NAME = sgtk_node_name[source]
SGTK_NODE_PARM = sgtk_node_parm[source]
SGTK_PATH_FILE = sgtk_path_selection3[source]
SGTK_PATH_PUBLISH = sgtk_path_selection1[source]
SGTK_PATH_SELECTION = sgtk_path_selection11[source]
SGTK_PATH_WORK = sgtk_path_selection2[source]
SGTK_PUBLISH_DATA = sgtk_publish_data[source]
SGTK_WORK_FILE_DATA = sgtk_work_file_data[source]
SGTK_WORK_REFRESH_VERSIONS = sgtk_work_refresh_versions[source]
SGTK_WORK_RESOLVED_VERSION = sgtk_work_resolved_version[source]
SGTK_WORK_VERSION = sgtk_work_version[source]
VALID_FILE_TYPES = valid_file_types[source]
VERSION_POLICIES[source]
WORK_VERSION_REGEX[source]
WORK_VERSION_TEMPLATE = v{}[source]
_convert_path_to_houdini_seq(self, path)[source]

Convert incoming sequence paths into houdini formatted ones. ($F4)

Parameters

path (str) – The incoming file path.

Returns

A houdini-formatted sequence path.

_create_sgtk_folder(self, node)[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.

_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)

_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.

static _escape_publish_data(publish_data_str)[source]

Utility to escape publish data strings for json loading.

Parameters

publish_data_str (str) – The serialised publish data.

Returns

A string that json can deal with.

static _extract_versions(versions_and_statuses)[source]

Extract just the versions from the versions and statuses dict.

Parameters

versions_and_statuses (list(dict)) – The versions and statuses.

Return type

list(int)

_get_all_versions(self, node)[source]

Get all the available versions off the given node.

Parameters

node – A hou.Node instance.

Return type

list(int)

_get_all_versions_and_statuses(self, node)[source]
_get_file_versions(self, node)[source]

Get all the file versions from the stored data on this node.

Parameters

node – A hou.Node instance.

Return type

list(int)

_get_node_file_parms(self, parent_node)[source]

Get all the parameters on the given node that are of the type hou.stringParmType.FileReference.

Parameters

parent_node – A hou.Node instance.

Return type

list(str)

static _get_path_from_sg_data(data)[source]

Get the file path from the publish data.

Parameters

data (dict) – The publish data.

Returns

str

static _get_search_filters_from_publish_data(publish_data)[source]

Construct search filters from the publish data.

Parameters

publish_data (dict) – The publish data to use for the query.

Return type

list

_get_template_fields_and_work_versions(self, parent_node, parm_name)[source]

Get the template, template fields and all versions from the file path associated with the given node and parameter name.

This method will initially use the node handler for the given node to retrieve the template, then falls back to sgtk.Sgtk.template_from_path().

If no template can be found, all versions will be calculated using regexes that look for v# in the file path.

Parameters
  • parent_node – The node to retrieve the data from.

  • parm_name – The name of the parameter that contains the file path.

Returns

A tuple of sgtk.Template, dict and list(int)

_get_work_versions(self, node)[source]

Get all the versions from the stored data on this node.

Parameters

node – A hou.Node instance.

Return type

list(int)

_load_from_shotgun(self, node)[source]

Open a shotgun loader dialogue and populate the node from the selection made.

Parameters

node – A hou.Node instance.

_path_selection(self, node)[source]

Get the index of the current path selection.

Parameters

node – A hou.Node instance.

Return type

int

_populate_from_file_data(self, node)[source]

Populate the node’s File tab from the saved file data.

Parameters

node – A hou.Node instance.

_populate_from_work_file_data(self, node)[source]

Populate the node’s work file tab from the saved work file data.

Parameters

node – A hou.Node instance.

_refresh_file_path(self, node)[source]

Refresh the file paths generated by the node handler.

Parameters

node – A hou.Node instance.

_refresh_file_path_from_node(self, node)[source]

Use another node to populate the file path on this node.

Parameters

node – A hou.Node instance.

_refresh_file_path_from_path(self, node)[source]

Use another file path to update the file path on this node.

Parameters

node – A hou.Node instance.

_refresh_file_path_from_publish_data(self, node, publish_data)[source]

Refresh the file path from the given publish data.

Parameters
  • node – A hou.Node instance.

  • publish_data (dict) – The publush data to populate from.

_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.

_replace_version_in_path(self, path, version)[source]

Replace the version numbers in the file path with the given version.

Parameters
  • path – The old version path.

  • version – The version number to update the path to.

Returns

The updated file path.

_resolve_all_versions_from_path(self, path)[source]

Extract all the versions on disk from the given file path.

Looks for v# in the path to determine the version number.

If the path exists on disk, but does not contain a version number, 1 will be returned. An empty list will be returned if no files exist on disk.

Parameters

path – The path to check against.

Return type

list(int)

_resolve_all_versions_statuses(self, publish_data)[source]

Get all the available versions and their pipeline statuses from the given entity publish data.

Parameters

publish_data (dict) – The publish data to use for the query.

Returns

A list(dict) of versions and relating statuses.

_resolve_version(self, all_versions_and_statuses, current)[source]

From a given string, resolve the current version. Either a specified version or the next version in the sequence.

Parameters
  • all_versions_and_statuses (list(dict)) – All the existing versions and their pipeline status.

  • current (str) – The currently selected version option.

Return type

int

_resolve_work_version(self, all_versions, current)[source]

From a given string, resolve the current version. Either a specified version or the next version in the sequence.

Parameters
  • all_versions (list(int)) – All the existing versions.

  • current (str) – The currently selected version option.

Return type

int or NoneType

_restore_sgtk_parms(self, node)[source]

Restore any removed sgtk parameters onto the given node.

Parameters

node – A hou.Node instance containing sgtk parameters.

_retrieve_publish_data(self, node)[source]

Retrieve publish data off the given node.

Parameters

node – A hou.Node instance.

Return type

dict

_set_up_node(self, node, parameter_group)[source]

Set up a node for use with shotgun pipeline.

Parameters
  • node – A hou.Node instance.

  • parameter_group – A ParmGroup instance.

_update_publish_data_parm(self, node, publish_data, version_policy)[source]

Update the publish data parm on the node with the publish data and version policy.

Parameters
  • node – A hou.Node instance.

  • publish_data (dict) – The publish data.

  • version_policy (str) – The version policy.

_update_version_from_publish_data(self, node, publish_data, version_policy)[source]

Update the version parameter from the given publish data and version policy.

Parameters
  • node – A hou.Node instance.

  • publish_data (dict) – The publish data.

  • version_policy (str) – The version policy.

static _validate_publish_data(publish_data)[source]

Validate the publish data.

Must include: - entity - project - name - published_file_type

Return type

bool

enable_sgtk(self, kwargs)[source]

Callback to enable/disable the sgtk parameters.

get_input_paths(self, node)[source]

Get all the input paths from the given node.

Parameters

node – A hou.Node instance containing sgtk parameters.

Return type

list(str)

load_from_shotgun(self, kwargs)[source]

Callback to open a shotgun loader dialogue and populate the node from the selection made.

on_loaded(self, node)[source]

Extended to ensure versions are also refreshed on farm i.e. no UI.

Parameters

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

populate_file_versions(self, kwargs)[source]

Populate the file versions menu with all available versions and <LATEST>.

Return type

list(str)

populate_node_from_publish_data(self, node, publish_data, version_policy=None)[source]

Populate the node from the given publish data.

Parameters
  • node – A hou.Node instance.

  • publish_data (dict) – The publish data.

  • version_policy (str) – The version policy.

populate_node_parms_menu(self, kwargs)[source]

Populate the parameter name menu.

Return type

list(str)

populate_work_versions(self, kwargs)[source]

Populate the work versions menu with all available versions and <LATEST>.

Return type

list(str)

refresh_file_path_from_version(self, kwargs)[source]

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

refresh_from_file_path(self, kwargs)[source]

Callback to refresh the file path when the File tab is active.

refresh_from_file_selection(self, kwargs)[source]

Callback to refresh the node’s file path when the file selection is changed.

refresh_from_file_version(self, kwargs)[source]

Callback to refresh the file path when the file version parameter is changed.

refresh_from_node_selection(self, kwargs)[source]

Call back to refresh the file path when the node selection is changed.

refresh_from_parm_selection(self, kwargs)[source]

Callback to refresh the file path when the parameter selection is changed.

refresh_from_selection(self, kwargs)[source]

Callback to refresh the node’s file path when the tab selection changes.

refresh_from_work_version(self, kwargs)[source]

Callback to refresh the file path when the work version parameter is changed.

refresh_work_path(self, kwargs)[source]

Callback to refresh the file path when the Work tab is active.

property valid_file_types(self)[source]

List of all the valid file types for this node handler.

Return type

list(str)