Search - User list
Full Version: Save Decoration Recipe with Python
Root » Technical Discussion » Save Decoration Recipe with Python
DrWeeny
Hello !
I've recently join a gig where I have to think about hda management and I was looking at the new recipe tool in houdini.
After a test with the ui, I've started to figure out how I could do it in python but I can't reproduce the ui result.



basically for my first test, I wanted to provide a basic ropnetwork
in order to have a decoration option, I've created a network box, I select both use the ui and boom, everything works.
Now I have written this test script :

import hou

my_sel = hou.selectedItems()

# generic_tags: Sequence[hou.NetworkItem]=None ???

options= {
    "name" : "sop/ropnet::drwee::test",
    "label" : "cfx_ropnet_test",
    "location" : "C:/Users/DrWee/OneDrive/Documents/houdini20.5/otls/Recipes.hdanc",

    "central_node" : hou.item('/obj/my_char/my_ropnet'),
    "decorator_items" : my_sel,
    "nodetype_patterns" : "Sop/ropnet",
    "comment" : "",
    "generic_tags":my_sel,

    # options from correct json done with ui :
    "nodes_only": False,
    "central_children": True,
    "children": True,
    "central_editables": True,
    "editables": True,
    "flags": False,
    "parms": True,
    "parms_as_brief": True,
    "evaluate_parmvalues": False,
    "parmtemplates": "spare_only",
    "metadata": False,
    "verbose": False
}

hou.data.saveDecorationRecipe(**options)

# save_version_recipe(my_sel[1], "sop/ropnet::drwee::test", 1.0)



the script seems to work and save a new recipe :



but when I try to apply it, it only creates the box and spare params on the node itself. All children are ignored.



Anyone has tried to create a decoration recipe with python ? is there a parameter in the command I didn't fill correctly ?

Thanks a lot !
gorrod
Hi,
It does not seem to be in the hou.data documentation but you need to set the dict values of "target_children" and "target_editables" to True, "central_children" and "central_editables" has no effect.

Like so:
sel = hou.selectedItems()
node = sel[0]

opts = {
    "name": "sop/ropnet::test:testRecipe",
    "label": "TestRecipe",
    "central_node": node,
    "target_children": True,
    "target_editables": True,
    "decorator_items": sel,
    "children": True,
    "location": "C:/Users/Gorrod/Documents/houdini20.5/otls/Recipes.hdanc"    
}

hou.data.saveDecorationRecipe(**opts)

You can take a look at the scripts for the recipe creation and their UI under e.g:
C:\Program Files\Side Effects Software\Houdini 20.5.474\houdini\python3.11libs\hrecipes
This specific issue might come from line 186/187 in
C:\Program Files\Side Effects Software\Houdini 20.5.474\houdini\python3.11libs\hrecipes\core\networkcluster.py


Might be worth making an RFE to sideFX to adjust the documentation.
DrWeeny
Thanks you so much.
I've tried it today and it worked perfectly !
I've taken a look to the Enum in hrecipes like you suggested, I'm not sure why the post-process is not triggered. I will look at RFE, I never did one, it seems central_node and anchor_node are supposed to be good.
Anyway thanks a lot ! It is my first deving in houdini and it didn't come tome to look at the .py
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