How to make recipes work in Houdini using Python?

   144   2   0
User Avatar
Member
2 posts
Joined: Nov. 2016
Offline
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
300 posts
Joined: Jan. 2013
Offline
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
User Avatar
Member
2 posts
Joined: Nov. 2016
Offline
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!
  • Quick Links