How to make recipes work in Houdini using Python?

   91   1   0
User Avatar
Member
1 posts
Joined: Nov. 2016
Online
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)

Attachments:
recipes_b_2.jpg (28.3 KB)
recipes_b_1.jpg (39.6 KB)

User Avatar
Member
299 posts
Joined: Jan. 2013
Online
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.
Edited by alexwheezy - today 04:08:09
  • Quick Links