Houdini Engine for Maya
 All Files Pages


import maya.cmds as cmds
import maya.mel as mel

# load the plugin

# load the Maya scene
cmds.file("/tmp/test_sphere.mb", open=True, force=True)

# load the Houdini asset
asset = cmds.houdiniAsset(loadAsset=["/tmp/test_asset.hda", "Sop/test_asset"])

# speicfy the input geometries to be connectd to the asset
input_geos = [ "|pSphere1" ]

# construct a single string that represent a MEL string array
# wrap with { }
mel_string_array = "{{ {} }}".format(
    # separate by comma
    ", ".join(
        # quote each string
        ["\"{}\"".format(s) for s in input_geos]

# source MEL script for houdiniEngine_setAssetInput
cmds.eval("source houdiniEngineAssetInput")

# call MEL function to connect input geometry
# connect to an actual node input
mel.eval("houdiniEngine_setAssetInput {} {}".format(
    asset + ".input[0].inputNodeId",

# connect to an oppath parameter that accepts geometry
mel.eval("houdiniEngine_setAssetInput {} {}".format(
    asset + ".houdiniAssetParm.houdiniAssetParm_objpath1__node",

# call setAttr to set some attribute
cmds.setAttr("{}.houdiniAssetParm.houdiniAssetParm_height".format(asset), 2)

# to "click" a button that does not affect output geometry, use setAttr
cmds.setAttr("{}.houdiniAssetParm.houdiniAssetParm_some_button__button".format(asset), 1)
# may need to call dgeval() to force the click to be processed

# source MEL script for houdiniEngine_syncAssetOutput
cmds.eval("source houdiniEngineAssetSync")

# sync the asset if needed
cmds.eval("houdiniEngine_syncAssetOutput {}".format(asset))