Skip to content

Instantly share code, notes, and snippets.

Learning something new

Hans Palacios morphingdesign

Learning something new
View GitHub Profile
morphingdesign / hou_dataTypeConversions.h
Created February 9, 2021 05:29
Data type conversion operations specified for use in Houdini Vex
View hou_dataTypeConversions.h
//Convert integer to string
s@string_attribute = itoa(i@int_attribute);
//Convert string to integer
i@int_attribute = atoi(s@string_attribute);
//Convert string to float
f@float_attribute = atof(s@string_attribute);
morphingdesign /
Created January 24, 2021 02:49
Outline of RGB values for default Houdini node color palette.
# Sorted from left to right and top to bottom.
# Row 1
# Row 2
morphingdesign / hou_attributeToLocalVar.h
Created January 25, 2021 20:26
Create and map a point attribute to a local variable in Houdini, as an alternative to using the Attribute Create SOP.
View hou_attributeToLocalVar.h
// Create custom variable
int pt_id = i@ptnum;
// Assign variable to point attribute
i@pt_id = pt_id;
// Map point attribute to local variable
addvariablename(0, "pt_id", "PT_ID");
morphingdesign /
Last active February 18, 2023 20:21
List of available Houdini node shapes
editor = hou.ui.paneTabOfType(hou.paneTabType.NetworkEditor)
# Returned tuple of strings:
# ('rect', 'bone', 'bulge', 'bulge_down', 'burst', 'camera',
# 'chevron_down', 'chevron_up', 'cigar', 'circle', 'clipped_left',
# 'clipped_right', 'cloud', 'diamond', 'ensign', 'gurgle', 'light',
# 'null', 'oval', 'peanut', 'pointy', 'slash', 'squared', 'star',
# 'tabbed_left', 'tabbed_right', 'tilted', 'trapezoid_down',
# 'trapezoid_up', 'wave')
morphingdesign /
Last active October 10, 2022 16:30
Add custom parameters and folder to Houdini node
# Acquire node from network
node = hou.node('/obj/geo/node')
# Add folder used to collect all newly create parameters
folder = hou.FolderParmTemplate("folder", "Folder Name")
# Define folder type; default is Tabs. Set to Simple
# Add parameter types, defined by parameter name, label, and number of components
# Add float parameter
morphingdesign /
Last active December 7, 2021 22:42
Access all available UI preferences for a Network Editor pane in a Houdini desktop/session via Python.
# Access panes in the current Houdini desktop using the
# the hou.ui class with/out the hou.Desktop class.
panes = hou.ui.currentPaneTabs()
panes = hou.ui.curDesktop().currentPaneTabs()
(<hou.NetworkEditor panetab1>, <hou.PythonShell panetab2>)
# View current setting for each available preference for
# the selected Network Editor pane.
pane = panes[0]
morphingdesign /
Last active August 3, 2021 02:23
Method for setting parameter values with specified data type or expressions.
rotateNode = hou.node('obj/box1/transform1')
speed = 20
# set() used to specify param value with corresponding data type.
# However, it cannot be used to set the value with a non-compatible
# data type, such as a string channel reference. The use of
# setExpression() allows for such instances.
rotateNode.parm('ry').setExpression('ch("../box1/divrate2") * {}'.format(speed))
# Reference:
morphingdesign /
Created January 25, 2021 02:04
Get and set default colors for Houdini sticky notes, text, and network boxes.
# Get default Houdini OOTB colors for Sticky Notes, Text, and Network Boxes
# <hou.Color r=1, g=0.969, b=0.522>
# <hou.Color r=0, g=0, b=0>
# <hou.Color r=0.52, g=0.52, b=0.52>
# Set custom default colors for Houdini Sticky Notes and Network Boxes
# Sticky Notes set to white
morphingdesign / hou_padPieceNumber.h
Created May 14, 2021 01:37
Rename fracture piece @name attribute with padded numbering in Houdini VEX.
View hou_padPieceNumber.h
// Fractured pieces are generated with @name such as 'piece0', 'piece1', etc.
// The following prim wrangle renames each piece with a padded number.
// String var to hold padded piece number.
string new_name = sprintf("piece_%04d", opdigits(@name));
// Update piece name.
s@name = new_name;
morphingdesign / hou_staticDynamicValues.h
Created May 12, 2021 21:10
Differentiation between initializing static and dynamic values in Houdini VEX.
View hou_staticDynamicValues.h
// Static Values
variable = {0,1,2};
// Dynamic Values
variable = set(x,y,z);