Functions
basename()
→ str
Return only the filename portion of the current hip file.
name()
→ str
Return the name of the current hip file.
This function may or may not return a full path. If it’s a relative path,
then it is relative to os.getcwd()
. If you need to always get a full
path, use hou.hipFile.path() instead.
path()
→ str
Return a full path to the current hip file.
hasUnsavedChanges()
→ bool
Returns whether the current Houdini session has been modified since it was last saved. This function only works in a graphical session. In a non-graphical session it will always return True.
load(file_name, suppress_save_prompt=False, ignore_load_warnings=False)
Loads a hip file.
If suppress_save_prompt is False
, the function acts as if the
file was loaded via File ▸ Open…. It prompts you to save the
current file before loading the new file and displays any load errors in
a pop-up window. It also changes the name of the current file at the top
of the main window and adds the file name to the list of most recently
used files.
If the UI is not available (for example, if you run the function from hython), the suppress_save_prompt parameter is ignored and non- interactive load is always performed.
Raises hou.OperationFailed if the file to be loaded does not exist or cannot be opened. The same exception will also be raised if the method is called during shutting down or loading/saving a hip file. In each case, the exception instance message will reflect the failure reason.
Raises hou.LoadWarning if warnings are
generated during load and ignore_load_warnings
is False
.
The instance message will contain the warning text.
save(file_name=None, save_to_recent_files=True)
Saves the current session to a hip file.
file_name
The name or path to the file that will be written. If you attempt to
save a file to a directory that does not exist, the directory will be
created. If this parameter is None
, Houdini will use the current hip
file path.
save_to_recent_files
Whether Houdini will add this file to the contents of the File ▸ Open Recent Files list. This parameter is ignored when this function is called from a non-graphical session.
Raises hou.OperationFailed if the target file or directory cannot be created or if other errors occur during save. The same exception will also be raised if the method is called during shutting down or loading/saving a hip file. In each case, the exception instance message will reflect the failure reason.
setName(file_name)
Changes the name of the current session for the next time it is saved to a hip file.
file_name
can either be an absolute or relative file path. If it’s
relative, then it is interpreted as being relative to os.getcwd()
.
If the user subsequently chooses File ▸ Save, Houdini saves to a hip file with this name. Note that this function does not actually save the hip file. To both set the name of the current session and save it to a hip file, use hou.hipFile.save().
saveAndIncrementFileName()
Saves the current session to a hip file, automatically incrementing the file name.
Raises hou.OperationFailed if the target file or directory cannot be created or if other errors occur during save. The same exception will also be raised if the method is called during shutting down or loading/saving a hip file. In each case, the exception instance message will reflect the failure reason.
saveAsBackup()
Creates a numbered backup from the current session.
If a file with the same name as the current backup already exists, then
the backup is renamed to contain the next number in the sequence before
saving. The backup files are saved in the directory set in the
environment variable HOUDINI_BACKUP_DIR
. If HOUDINI_BACKUP_DIR
is not
set, then a default relative directory called "backup" is used.
Raises hou.OperationFailed if the target file or directory cannot be created or if other errors occur during save. The same exception will also be raised if the method is called during shutting down or loading/saving a hip file. In each case, the exception instance message will reflect the failure reason.
clear(suppress_save_prompt=False)
This function replaces the current session with an empty session.
If suppress_save_prompt
is set to False
, the method acts as File ▸ New in an interactive session. It prompts you to save the current file
before clearing. Otherwise, the session is cleared non-interactively: no
prompts appear and any changes are discarded.
If the UI is not available (for example, if you run the method from hython), the suppress_save_prompt parameter is ignored and non- interactive clear is always performed.
merge(file_name, node_pattern="*", overwrite_on_conflict=False, ignore_load_warnings=False)
Merges the given file into the current hip file. The nodes to merge in are indicated by the node_pattern parameter.
If overwrite_on_conflict
is True
, the method will
overwrite nodes with the same name as nodes in the merge file.
This method will raise a hou.OperationFailed exception if the file to be merged into the current one does not exist or cannot be opened. The same exception will also be raised if the method is called during shutting down or loading/saving a hip file. In each case, the exception instance message will reflect the failure reason.
This method will raise a hou.LoadWarning exception if warnings are
generated during merge and ignore_load_warnings
is False
. The instance
message will contain the warning text.
collisionNodesIfMerged(file_name, node_pattern="*")
→ tuple of hou.Node
Returns the Nodes that would collide if a merge was performed with the specified node_pattern.
The result is a tuple of all Nodes in the merge file satisfying the node_pattern and having the same name as any of the existing nodes.
Raises hou.OperationFailed if the file to be used in the collision check does not exist, cannot be opened, or is not a valid hip file. The same exception will also be thrown if the method is called during shutting down or loading/saving a hip file. In each case, the exception instance message will reflect the failure reason.
isLoadingHipFile()
→ bool
Return whether the main application is loading a hip file.
isShuttingDown()
→ bool
Return whether the main application is shutting down.
setOnSaveCallback(callback)
groupColorTable()
→ dict
of str
to hou.Color
Returns a dictionary of color overrides for the viewport group list. The viewport group list automatically assigns colors to groups based on a hash of the group name. The group color table is a dictionary of overrides to these default color assignments. This allows particular important groups to be assigned distinctive colors. The group color table is saved with the hip file. The color table can be modified with hou.hipFile.setGroupColorTable().
setGroupColorTable(color_table)
Sets a dictionary of color overrides for the viewport group list. The viewport group list automatically assigns colors to groups based on a hash of the group name. The group color table is a dictionary of overrides to these default color assignments. This allows particular important groups to be assigned distinctive colors. The group color table is saved with the hip file. The current color table can be queried with hou.hipFile.groupColorTable().
The supplied color_table
must be a dict
of str
to hou.Color. The
following example will cause groups names 'special_group' to appear with a
red overlay:
color_table = { 'special_group' : hou.Color([1,0,0]) } hou.hipFile.setGroupColorTable(color_table)
saveMode()
→ hou.saveMode
Return the save mode of the current scene, either hou.saveMode.Binary or hou.saveMode.Text.
setSaveMode(save_mode)
Set the save mode of the current scene to either hou.saveMode.Binary or hou.saveMode.Text.
importFBX(file_name, suppress_save_prompt=False, merge_into_scene=True, import_cameras=True, import_joints_and_skin=True, import_geometry=True, import_lights=True, import_animation=True, import_materials=True, resample_animation=False, resample_interval=1.0, override_framerate=False,framerate=-1, hide_joints_attached_to_skin=True, convert_joints_to_zyx_rotation_order=False, material_mode=hou.fbxMaterialMode.FBXShaderNodes, compatibility_mode=hou.fbxCompatibilityMode.Maya, single_precision_vertex_caches=False, triangulate_nurbs=False, triangulate_patches=False, import_global_ambient_light=False, import_blend_deformers_as_blend_sops=False, segment_scale_already_baked_in=True, convert_file_paths_to_relative=True, unlock_geometry=False, unlock_deformations=False, import_nulls_as_subnets=False, import_into_object_subnet=True, convert_into_y_up_coordinate_system=False)
→ (hou.ObjNode, str
)
Imports an FBX file with various options. It is recommended to always call this function with keyword arguments. Please see the __File > Import > Filmbox FBX__ dialog help for a description of the options.
If suppress_save_prompt is False
, the function acts as if the
file was loaded via File ▸ Open…. It prompts you to save the
current file before loading the new file and displays any load errors in
a pop-up window. It also changes the name of the current file at the top
of the main window and adds the file name to the list of most recently
used files.
If the UI is not available (for example, if you run the function from hython), the suppress_save_prompt parameter is ignored and non- interactive load is always performed.
Raises hou.OperationFailed if the file to be loaded does not exist or cannot be opened. The same exception will also be raised if the method is called during shutting down or loading/saving a hip file. In each case, the exception instance message will reflect the failure reason.
This function returns a tuple consisting the parent subnet node of the
imported FBX nodes (or hou.node('/obj')
if import_into_object_subnet
is
False
) and a string containing the generated load messages.
addEventCallback(callback)
Register a Python callback to be called whenever a .hip file event occurs (i.e. file load, file save).
callback
Any callable Python object that expects one argument. The argument is an hou.hipFileEventType enum value.
See how to write a scene event callback for more information.
def scene_event_callback(event_type): hou.ui.displayMessage("An event of type {} occured".format(event_type)) hou.hipFile.addEventCallback(scene_event_callback)
removeEventCallback(callback)
Remove a Python callback that was previously registered with hou.hipFile.addEventCallback(). See hou.hipFile.addEventCallback() for more information.
Raises hou.OperationFailed if the callback was not previously registered.
clearEventCallbacks()
Remove all Python callbacks that have been registered with hou.hipFile.addEventCallback().
eventCallbacks()
→ tuple
of callback
Return a tuple of all the Python callbacks that have been registered with hou.hipFile.addEventCallback().