Search - User list
Full Version: How to make recipes work in Houdini using Python?
Root » Technical Discussion » How to make recipes work in Houdini using Python?
Pushpin
Hi! I'm trying to automate node creation in Houdini using Python. Specifically, I want to create nodes saved as a tab recipe. However, I keep getting an error. What am I doing wrong?

asset = hou.selectedNodes()[0]

pane_tab = hou.ui.paneTabOfType(hou.paneTabType.NetworkEditor)
recipe_name = "test"
node_position_x = 0
node_position_y = 0

kwargs = {
    "pane": pane_tab,
    "inputs": [asset.path()],  
    "outputs": [],  
    "nodepositionx": node_position_x,
    "nodepositiony": node_position_y,
}

hou.data.applyTabToolRecipe(recipe_name, kwargs)

This code doesn't work as well:
asset.hou.data.applyTabToolRecipe(recipe_name, kwargs)
alexwheezy
Let's take a look at the body of the applyTabToolRecipe function.

def applyTabToolRecipe(name: str,
                       kwargs: dict = None,
                       **tabtoolrecipe_set_opts):
    from hrecipes import rtypes
    from hrecipes import storage

    ref = storage.refByInternalName(name, rtypes.RecipeCategory.tabTool)
    return ref.applyRecipe(kwargs, **tabtoolrecipe_set_opts)

The function on the ref variable should return the recipe by its internal name, but you haven't created it yet, so the result is None. Before applying the recipe, you must first call the hou.data.saveTabToolRecipe method.
Pushpin
Thank you, Alexwheezy! I found the mistake in my code. I used not full name of the recipe I had saved. So, it should be like in Recipe Manager (Windows - Recipe Manager) in "Internal Name" column. So, in my case it should be not just "test", but "user::test". And everything works fine!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB