On this page

MaxScript

The Houdini Engine for 3ds Max plug-in supports basic scripting functionality via MaxScript. The scripting functionality allows for the creation of HDAs, changing parameter values, and cooking an HDA.

MaxScript Functions

Method

Success Return Value

Failure Return Value

Description

CreateSession <>

True

False

This will start an out-of-process HARS Thrift named pipe thin client and then create a session using the thin client

CloseSession <>

True

If there is an active session, this will close the session

IsSessionActive <>

Bool (True/False)

This method will return true if a Houdini Engine session is active and false otherwise

IsHdaLoaded <HdaPath::Required>

Bool (True/False)

This method will check if an HDA is loaded and return true or false depending on if it is loaded. An HDA is identified by its filepath

LoadHda<HdaPath::Required>

True

False

This will load an HDA. It will return true if the asset was successfully loaded and false otherwise

CreateGeometryHda <PathToHda::required> <AssetIndex::default=0>

INode

Undefined

Creates a geometry object HDA in the scene from the specified HDA using the specified asset (0 by default). If it succeeds, it will return the top-level container INode (containing the Dummy object). If the operation fails, it will return an undefined value

CreateModifierHda <INode::required> <PathToHda::required> <AssetIndex::default=0>

True

False

Creates a modifier HDA on the specified node from the specified HDA using the specified asset (0 by default). If it succeeds, it will return the created Modifier. If the operation fails, it will return an undefined value

CookHda <INode::required>

True

False

Cooks a geometry HDA. The method must be passed the container node (INode containing the dummy object) of the geometry HDA

CookHda<INode::required> <Modifier::required>

True

False

Cooks a modifier HDA. The method must be passed the INode and Modifier in order to identify the HDA to cook

DeleteHda <INode::required>

True

When passed the container node of a geometry HDA, this method will fully delete the HDA from the scene. If the HDA is not found, this method will throw a RuntimeError exception

DeleteHda <INode::required> <Modifier::required>

True

When passed a modifier HDA and the node that it belongs to, this method will delete the HDA from the modifier stack of the node. If the HDA is not found, this method will throw a RuntimeError exception

GetGeometryHdas <>

Array <MAXNode>

Returns a list of container nodes for all of the geometry HDAs in the scene

GetHdaType<INode::required>

Name

When passed the container node of a geometry HDA, this method will return the HDA type. If an HDA is not found, this method will throw a RuntimeError exception

GetHdaType<INode::required> <Modifier::required>

Name

When passed a modifier HDA and the node that it belongs to, this method will return the HDA type. If an HDA is not found, this method will throw a RuntimeError exception

GetHdaParameterValue <INode::required> <Parameter Name::required> <Index::required>

Float, Integer, String, MAXNode

False

This method will retrieve the value of a parameter from a geometry HDA. An index argument must be supplied which specifies the tuple index of the value to be retrieved. This method will return a Float value, Integer value, String value, or MAXNode value depending on the type of the parameter

GetHdaParameterValue <INode::required> <Modifier::required> <Parameter Name::required> <Index::required>

Float, Integer, String, MAXNode

This method will retrieve the value of a parameter from a modifier HDA. An index argument must be supplied which specifies the tuple index of the value to be retrieved. This method will return a Float value, Integer value, String value, or MAXNode value depending on the type of the parameter

SetGeometryHdaParameter <INode::required> <ParameterName::required> <ListOfValues::required>

True

False

This function updates the parameter of a geometry HDA specified by the node and parameter name. The ListOfValues is where the values of the parameter are specified. The values specified in this list must all be of the same type (e.g. 3 floats for a position parameter). This method will return True on success and will return False if something went wrong and the operation failed

SetModifierHdaParameter <INode::required> <Modifier::required> <ParameterName::required> <ListOfValues::required>

True

False

This function updates the parameter of a modifier HDA specified by its node, modifier, and parameter name. The ListOfValues is where the values of the parameter are specified. The values specified in this list must all be of the same type (e.g. 3 floats for a rotation parameter). This method will return True on success and will return False if something went wrong and the operation failed

BakeHda <INode::required>

INode

Undefined

This method will bake out a geometry HDA. The method must be passed the container node (INode containing the dummy object) of the geometry HDA. If the operation succeeds, it will return the container node (Node containing the dummy object) of the baked out geometry. If the operation fails, it will return an undefined value

CopyModifierHda <SourceINode::required> <SourceModifier::required> <DestinationINode::required>

Modifier

Undefined

Copies a modifier HDA and all of its parameter values onto another node. If the operation succeeds, it will return the created Modifier. If the operation fails, it will return an undefined value

CloneObjectHda <INode::required>

INode

Undefined

Clones the specified object HDA and all of its parameter values. The INode passed to this function must be the top-level node of the object HDA, not any of its children nodes. If the operation succeeds, it it will return the top-level container INode (containing the Dummy object) of the cloned object HDA. If the operation fails, it will return an undefined value

GetListOfGeometryHdaParameters <INode::required>

Array <Name>

Undefined

This will return a list of the names of all the parameters on the geometry HDA. The function must be passed the the top-level container node (the INode containing the dummy object) of the HDA. On success, it will return an Array of Names that are the parameter names of the HDA. On failure, it will return undefined

GetListOfModifierHdaParameters <INode::required> <Modifier::required>

Array <Name>

Undefined

This will return a list of the names of all the parameters on the modifier HDA. This function must be passed the INode and Modifier to identify the HDA. On success, it will return an Array of Names that are the parameter names of the HDA. On failure, it will return undefined

SetGeometryHdaInput <INode::required> <Integer::required> <INode/undefined::required>

True

False

This method allows a subnetwork input to be set on a geometry HDA. The first argument specifies the container node (INode containing the dummy object) of the geometry HDA. The second argument specifies the index (0-based) of the subnetwork. The third argument specifies the INode of the geometry to be used as the input. If undefined is passed instead of an INode, this method will remove the input

SetModifierHdaInput <INode::required> <Modifier::required> <Integer::required> <INode/undefined::required>

True

False

This method allows a subnetwork input to be set on a modifier HDA. The first argument specifies the INode of the modifier, and the second argument specifies the modifier itself. The third argument specifies the index (0-based) of the subnetwork. The fourth arugment specifies the INode of the geometry to be used as the input. If undefined is passed instead of an INode, this method will remove the input

SetGeometryHdaOpParmInput <INode::required> <String::required> <INode/undefined::required>

True

False

This method allows an operator path parameter input to be set on a geometry HDA. The first argument specifies the container node (INode containing the dummy object) of the geometry HDA. The second argument specifies the name of the operator path parameter. The third argument specifies the INode of the geometry to be used as the input. If undefined is passed instead of an INode, this method will remove the input

SetModifierHdaOpParmInput <INode::required> <Modifier::required> <String::required> <INode/undefined::required>

True

False

This method allows an operator path parameter input to be set on a modifier HDA. The first argument specifies the INode of the modifier, and the second argument specifies the modifier itself. The third argument specifies the name of the operator path parameter. The fourth argument specifies the INode of the geometry to be used as the input. If undefined is passed instead of an INode, this method will remove the input

SetGeometryHdaAutoRecookingEnabled <INode::required> <boolean::required>

True

False

Sets whether auto recooking is enabled for the geometry HDA. When auto recooking is enabled, the node will automatically cook whenever a parameter value is changed

SetModifierHdaAutoRecookingEnabled <INode::required> <Modifier::required> <boolean::required>

True

False

Sets whether auto recooking is enabled for the modifier HDA. When auto recooking is enabled, the node will automatically cook whenever a parameter value is changed

SetHdaSelectionLocked <boolean::required>

True

If passed true, this will lock the parameter user interface to the current HDA selection if an HDA is selected. If passed false, this will unlock the parameter user interface’s selection

GetHoudiniEngineOption <String::required: Option Name>

String, Boolean, Integer

False

Gets the value of a Houdini Engine option. The supplied name must be one of the settings listed here. This method will return a String, Boolean, or Integer depending on the type of the option

SetHoudiniEngineOption <String::required: Option Name> <*::required: Option Value>

True

This method will set a Houdini Engine option. The supplied name must be one of the settings listed here. The second argument can be a String, Boolean, or Integer, and must match the option type

GetHoudiniVersion <>

Array <String>

Returns an array that contains the Houdini versions (major, minor, and build number)

Samples

Setting a float parameter and float vector parameter

LoadHda "C:/Assets/sample.hda"
myHda = CreateGeometryHda "C:/Assets/sample.hda"
SetGeometryHdaParameter myHda "singlefloat" 5.5
SetGeometryHdaParameter myHda "floatvec" 2.2 3.3 4.4

Setting a integer parameter and integer vector parameter

LoadHda "C:/Assets/sample.hda"
myHda = CreateGeometryHda "C:/Assets/sample.hda"
SetGeometryHdaParameter myHda "singleinteger" 2
SetGeometryHdaParameter myHda "integervec" 3 4 5

Setting a string parameter

LoadHda "C:/Assets/sample.hda"
myHda = CreateGeometryHda "C:/Assets/sample.hda"
SetGeometryHdaParameter myHda "singlestring" "Hello, world!"

Create modifier and geometry HDA, set integer parameters, and cook the HDAs

CreateModifierHda $Teapot001 "C:/Program Files/Autodesk/3ds Max 2018/Plugins/MountainModifierHDA.hda" 0
SetModifierHdaParameter $Teapot001 $Teapot001.MountainModifier "height" 5

CreateGeometryHda "C:/Program Files/Autodesk/3ds Max 2018/Plugins/SideFX_spaceship.otl" 0
SetGeometryHdaParameter $spaceship1 "smoothness" 1

CookHda $Teapot001 $Teapot001.MountainModifier
CookHda $spaceship1

Create session, create a geometry HDA, and bake the HDA

CreateSession()
LoadHda "C:/Assets/spaceship.hda"
geoHda = CreateGeometryHda "C:/Assets/spaceship.hda"
BakeHda geoHda

Setting the input of an HDA

mountainHda = CreateGeometryHda "C:/Assets/mountain.hda"
SetGeometryHdaInput mountainHda 0 $Teapot001  

Setting an operator path parameter

booleanHda = CreateModifierHda $Sphere001 "C:/Assets/boolean.hda"
SetModifierHdaOpParmInput $Sphere001 booleanHda "objpath1" $Box001  

Setting a multiparameter length and setting instance parameter values

myHda = CreateGeometryHda "C:/Assets/multiparm_test.hda"
SetGeometryHdaParameter myHda "integer_list" 3
SetGeometryHdaParameter myHda "my_int_parm_1" 1
SetGeometryHdaParameter myHda "my_int_parm_2" 2
SetGeometryHdaParameter myHda "my_int_parm_3" 3    

Python

Because MaxScript can be executed from a Python script, the plug-in’s MaxScript API is also available to be used via Python. Below is an example of how to execute MaxScript function from a Python script:

import MaxPlus
MaxPlus.Core.EvalMAXScript("CreateGeometryHda #'C:/Program Files/Autodesk/3ds Max 2018/Plugins/SideFX_spaceship.otl' 0")

Houdini Engine for 3ds Max

Getting started

Using Houdini Engine

Reference