Houdini Engine for 3ds Max
 All Files Pages
Scripting

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

Name Signature Success Return Value Failure Return Value Description
CreateSession 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 CloseSession <> True N/A If there is an active session, this will close the session.
IsSessionActive IsSessionActive <> Bool (True/False) N/A This method will return true if a Houdini Engine session is active and false otherwise.
IsHdaLoaded IsHdaLoaded<HdaPath::Required> Bool (True/False) N/A 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 LoadHda<HdaPath::Required> True False This will load an HDA. It will return true if the asset was successfully loaded and false otherwise.
CreateGeometryHda 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 CreateModifierHda <INode::required> <PathToHda::required> <AssetIndex::default=0> Modifier Undefined 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 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 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.
SetGeometryHdaParameter 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 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 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 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::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.
SetModifierHdaInput <INode::required> <Modifier::required> <Integer::required> <INode::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.
SetGeometryHdaOpParmInput <INode::required> <String::required> <INode::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.
SetModifierHdaOpParmInput <INode::required> <Modifier::required> <String::required> <INode::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.
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 N/A 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.

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:

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