Houdini 22.0 Character KineFX

Creating graph interfaces

Create and customize interfaces for graph inputs using APEX Script.

On this page

APEX Script can be used to create and customize interfaces for graph inputs (parameters). Using APEX Script, you can organize parameters into multiparms and folders, specify the parameters to hide and disable, and add drop-down menus containing tags, attributes, and control shapes.

Graph interface created by APEX Script

Creating an interface for graph inputs

The BindInput() function is used to define the inputs to a graph. These inputs can appear in the parameter editor as values you can adjust:

  1. On an APEX Script SOP, put the following code in the Snippet parameter:

    # Inputs of different types
    a: Int = BindInput(2)
    b: Vector4 = BindInput((1, 2, 3, 4))
    c: String = BindInput('hello')
    
    # Color ramp
    Colorful: ColorRamp = BindInput(
        ColorRamp(basis=["Bezier", "Linear", "Bezier"], 
                  keys=[0.2, 0.5, 1.0], 
                  values=Vector3Array((1,0,0), (0,1,0), (0,0,1))))
    

    See ramps for more information on setting FloatRamp and ColorRamp values.

  2. To have the inputs appear in the parameter editor, click the Reload Setup Parms button:

Configuring parameters

In the BindInput() function, the preset_kwargs keyword argument can be used to configure the following interface properties of a parameter:

preset_kwargs

Type

Description

disable_when

String

Disables the parameter based on the values of another parameter.

hide_when

String

Hides the parameter based on the values of another parameter.

joins_with_next

Int

If set to 1, puts the parameter on the same line as the next parameter.

label

String

Creates a label for the parameter.

prompt_text

String

Adds text to the string parameter field that hints at what to do with the string.

In this example, we configure various parameters using the preset_kwargs argument:

  1. On an APEX Script SOP, put the following code in the Snippet parameter:

    # Rename the label on a string parameter and
    # add prompt text in the string field
    a: String = BindInput(
        '', preset_kwargs={'label':'Favorite sport', 
                           'prompt_text':'on ice'})
    
    # Put two parameters on the same line 
    x: Int = BindInput(1, preset_kwargs={'joins_with_next':1})
    y: Float = BindInput(3.5)
    
  2. Click the Reload Setup Parms button. The inputs appear in the parameter editor:

  3. Hide and disable parameters:

    g: Bool = BindInput(False)
    
    # Hide this parameter when 'g' is turned off
    h: Int = BindInput(1, preset_kwargs={'hide_when':'{g == 0}'})
    
    # Disable this parameter when 'h' is set to '1'
    i: Int = BindInput(1, preset_kwargs={'disable_when':'{h == 1}'})
    

Presets

In the BindInput() function, you can use the preset keyword argument to specify the type of parameter you want to create. Some of the presets have additional options that can be set using the preset_kwargs keyword. The available presets are:

Color

The color preset creates a color parameter for a vector (Vector3 or Vector4). For a Vector3, the color is RGB. For a Vector4, it’s RGBA.

There are no preset_kwargs for this preset.

Example

On an APEX Script SOP, put the following code in the Snippet parameter:

a: Vector3 = BindInput((0, 0.3, 1), preset='color')

Click the Reload Setup Parms button to update the parameter interface:

VEX

The vex preset creates a multiline VEX string. It is available for string parameters.

There are no preset_kwargs for this preset.

Example

On an APEX Script SOP, put the following code in the Snippet parameter:

teststring: String = BindInput('@P = @N;', preset='vex')

Click the Reload Setup Parms button to update the parameter interface:

Python

The python preset creates a multiline Python string. It is available for string parameters.

There are no preset_kwargs for this preset.

Example

On an APEX Script SOP, put the following code in the Snippet parameter:

pythonstring: String = BindInput(
    'n = hou.node("/obj/geo1/attribwrangle1")', 
    preset='python')

Click the Reload Setup Parms button to update the parameter interface:

Control shapes

The controlshapes preset creates a drop-down menu of the available control shapes on an unpacked character. The control shapes preset is available for string parameters.

There are no preset_kwargs for this preset.

Example

To add a drop-down menu of control shapes for the Electra test geometry:

  1. On the Electra test geometry SOP, set Output to APEX Character.

  2. Connect the 1st output of the Electra SOP to an APEX Script SOP.

  3. On the APEX Script SOP, put the following code in the Snippet parameter:

    a: String = BindInput('', preset='controlshapes')
    
  4. Click the Reload Setup Parms button to update the parameter interface.

Tags

The tags preset creates a drop-down menu of the available tags on a geometry, and is available for string parameters. Tags can be found on both skeletons and graphs.

The tags preset has the following preset_kwargs:

preset_kwargs

Type

Description

path

String

The path to a geometry. If path is set to the empty string (''), the geometry is treated as an unpacked geometry. Otherwise, the geometry is treated as a packed geometry. If there is no path preset_kwargs, the geometry defaults to the packed geometry, /Base.rig.

usepattern

Bool

If set to True, adds a “#” before the tag name. If usepattern is not specified, it defaults to True.

Example

In this example, we first add tags to the Electra test geometry using an Attribute Adjust Array SOP:

Tags on Electra

On the APEX Script SOP, put the following code in the Snippet parameter:

t1: String = BindInput(
    '', 
    preset='tags', 
    preset_kwargs={'path':'', 'prompt_text':'side'})

t2: String = BindInput(
    '', 
    preset='tags', 
    preset_kwargs={'path':'', 'usepattern':False})

Click the Reload Setup Parms button to update the parameter interface:

Attributes

The attrib preset creates a drop-down menu that lists the attributes of a specific type (for example, string) and class (for example, primitive). The attribute preset is available for string parameters.

The attrib preset has the following preset_kwargs:

preset_kwargs

Type

Description

path

String

The path to a geometry. If path is set to the empty string (''), the geometry is treated as an unpacked geometry. Otherwise, the geometry is treated as a packed geometry. If there is no path preset_kwargs, the geometry defaults to the packed geometry, /Base.shp.

attrib_type

String

The attribute type, for example, String or Float. If attrib_type is not specified, it defaults to Float.

attrib_class

String

The attribute class - the valid options are detail, point, primitive, and vertex. If attrib_class is not specified, it defaults to point.

Example

In this example, we add a string attribute (tags) and an integer attribute to the Electra test geometry:

  1. Add tags using an Attribute Adjust Array SOP.

  2. Add an integer detail attribute using an Attribute Adjust Integer SOP:

    • Set Attribute Name to hello.

    • Set Attribute Class to Detail.

  3. On the APEX Script SOP, put the following code in the Snippet parameter:

    string_attrib: String = BindInput(
        '*', 
        preset='attrib', 
        preset_kwargs={'path': '', 
                       'attrib_type': 'String'})
    
    int_detail_attrib: String = BindInput(
        '*', 
        preset='attrib', 
        preset_kwargs={'path': '', 
                       'attrib_type': 'Int', 
                       'attrib_class': 'detail'})
    
  4. Click the Reload Setup Parms button. The updated parameter interface has the following menu items:

    Parameter

    Menu items

    Attribute From

    string_attrib

    name, tags

    The name attribute is from the Electra SOP, and the tags attribute is created by the Attribute Adjust Array SOP.

    int_detail_attrib

    hello

    The hello attribute is created by the Attribute Adjust Integer SOP.

Adding parameters to folders

You can use the addToFolder() function to organize parameters into folders. The syntax for addToFolder() is:

addToFolder(<folder_name>, <list_of_inputs>, [foldertype=<folder_type>, parent=<parent_folder>])

Argument

Type

Description

folder_name

String

The name of the folder.

Note

Spaces in the folder name are not supported.

list_of_inputs

List of variables

A list of bound variables (variables declared with the BindInput() function) to add to the folder.

folder_type

String

(Optional) The type of folder to create. The valid options are folder_tabs, folder_simple, folder_collapsible, and folder_radio. The default is folder_tabs.

parent_folder

String

(Optional) The folder hierarchy path to put the folder_name under. If the folders in the path don’t exist, they will be created.

Example

On an APEX Script SOP, put the following code in the Snippet parameter:

a: Int = BindInput(2)

b: String = BindInput('hello')

c: Float = BindInput(3.5)

d: Vector3 = BindInput((1,3,5))

e: Bool = BindInput(True)

addToFolder('Folder1', [a, b])

addToFolder('Folder2', [c])

addToFolder('Nested', [d], parent='Folder1')

addToFolder('Simple', [e], foldertype='folder_simple')

Click the Reload Setup Parms button to update the parameter interface:

If the folders in the parent argument don’t exist, they will be created:

good: Bool = BindInput(True)

addToFolder('Bottom', [good], parent='Top/Mid')

Multiparms

To add a multiparm to a parameter interface:

  1. Use the bindMultiparm() function to create a new multiparm. bindMultiparm() does not require any arguments.

  2. Use the addToMultiparm() function to add elements to the multiparm. The syntax for addToMultiparm() is:

    addToMultiparm(<multiparm>, <variable_name>, <default_value>, [preset=<preset>, preset_kwargs=<preset_kwargs>])

Argument

Type

Description

multiparm

Variable

The multiparm variable created with bindMultiparm().

variable_name

String

The name of the variable to add to the multiparm.

default_value

Any

The default value to set for the added element.

preset

String

(Optional) A preset for the variable.

preset_kwargs

Dictionary

(Optional) You can use any of the preset_kwargs for presets or configuring parameters.

Example

On an APEX Script SOP, put the following code in the Snippet parameter:

a = bindMultiparm()
b = bindMultiparm()

addToMultiparm(a, 'hello', 'jello')

addToMultiparm(a, 'again', (2,4,6))

addToMultiparm(b, 'xyz', 1, 
    preset='menu', 
    preset_kwargs={'menu_items':['x','y','z']})

Click the Reload Setup Parms button to update the parameter interface:

Note

Multiparms are dictionary arrays. To fetch the vector, again, from the above multiparm:

v: Vector3 = a[0]['again#']

KineFX

Overview

Preparing character elements

Rigging with APEX graphs

  • APEX graph basics

    Introduction of the APEX graph evaluation framework.

  • APEX graph debugger

    Inspect the values of an APEX graph’s ports within the APEX network view.

  • APEX Script basics for graph building

    An overview of APEX Script, a code interface for building APEX graphs.

  • Graphs for numerical operations

    Example graphs of numerical operations like adding two values, fetching multiple results, and retrieving information from geometry.

  • Graphs for viewport animation

    Example graphs of animate state functionality like creating controls and constraints, and defining joint hierarchies.

  • Graphs for deforming geometry

    Example of a SOP network and APEX graph for deforming a 3-joint tube geometry.

  • Graph metadata

    Information added to graph nodes and ports.

  • APEX path pattern

    A set of rules that allow you to filter and select elements within graphs, skeletons, geometry, and the character folder structure.

  • APEX graph nodes

    APEX nodes provide operations for building up the functionality of APEX graphs, which are used in KineFX to create character rigs and perform other geometry manipulation.

  • APEX updates for H22

    New and updated APEX graph nodes for Houdini 22.

Building rig graphs with APEX Script

Rigging with rig components

Animating in the viewport

  • Animation workflow

    Example networks of adding characters, props, characters, and animation to a scene.

  • Animating in LOPs

    Rig and animate characters and props in the context of a USD stage.

  • Working in the animate state

    Select and manipulate controls, define transform limits for controls, and add skin controls to a character.

  • Animate state menus and HUDs

    Menus, HUDs, toolbars, and options in the animate state.

  • Animate state hotkeys

    Hotkeys available in the animate state.

  • Posing

    Pose characters in the animation scene by using locators, copying and pasting controls, and mirroring poses.

  • Motion paths

    Visualize the motion of controls as curves in 3D space.

  • Constraints

    Create relationships between controls in the animate state.

  • Dynamic motion

    Add physically-accurate projectile motion to your animation in the animate state.

  • Ragdoll

    Add a ragdoll simulation to your animation in the animate state.

  • Full body IK

    Apply full body inverse kinematics to pose the character using high-level targets rather than manipulating individual joints.

  • Secondary motion

    Add physically-accurate effects like lag/overshoot, jiggle, and spring to your animation in the animate state.

  • Control selection sets

    A tree view of controls, selections, and selection sets for the animate state. Allows management of control selection and visibility.

  • Motion mixer

    Combine and edit the animation clips of multiple characters in a timeline-based view.

  • Character picker

    Create a 2D layout with simple buttons for selecting character controls in an animation scene.

  • Animation catalog

    Save, manage, and apply animations and single-frame poses to an animation scene.

  • Animation layers

    Create multiple layers of animation without affecting the original animation.

  • Animation toolbar

    A customizable toolbar consisting of simple slider tools that quickly apply modifications to animation controls and curves.

  • Animation bookmarks

    Frame markers that help organize and identify the different parts of your animation.

Customizing the animate state

SOP-based animation

  • Physics-based motion

    Add physically-accurate motion to your animation using the Projectile Motion and Pendulum Motion SOPs.

  • Ragdoll simulations

    Add a ragdoll simulation to your animation using the Ragdoll Solver SOP.

Deformation

  • Blend shapes

    Create blend shapes using blend shape SOP nodes.

Animation retargeting

Pre-H20

Panes

  • Motion mixer

    A timeline-based view of the animation clips and motion effects of multiple characters.

  • Character picker

    Create a 2D layout with simple buttons to select character controls in an animation scene.

  • Rig tree view

    A hierarchical view of character components, including packed character folders, KineFX rigs, and Object node rigs.

  • Animation editor

    View and edit animated parameters and their transitions between keyframes.

  • Geometry spreadsheet

    Displays details about the geometry selected in the network editor.

Appendix