params = node.parmTemplateGroup() ogParms = node.parms() # create a digital asset from the given node hdaNode = node.createDigitalAsset( name=name, hda_file_name=filepath, max_num_inputs=1, version=str(version), ignore_external_references=True, create_backup=False) # restore the nodes params hdaNode.type().definition().setParmTemplateGroup(params) # save the digital asset again # after restoring it's params hdaNode.type().definition().updateFromNode(hdaNode) hdaNode.matchCurrentDefinition()
Set the default values for an HDA via Python
6461 8 1- blented
- Member
- 61 posts
- Joined: 10月 2013
- Offline
When saving an HDA via python, how can I set the default values for said HDA? I'm able to copy the parameters via the following code, but would love to set their initial values as defaults as well.
Grant Miller
VFX Supervisor
Ingenuity Studios
VFX Supervisor
Ingenuity Studios
- goldfarb
- スタッフ
- 3464 posts
- Joined: 7月 2005
- Offline
you'll have to use hscirpt right now - there is an RFE to have a HOM version of “Copy Defaults From Nodes”
see http://www.sidefx.com/docs/houdini/commands/otwrite.html [www.sidefx.com]
otwrite -i -o -l
see http://www.sidefx.com/docs/houdini/commands/otwrite.html [www.sidefx.com]
- blented
- Member
- 61 posts
- Joined: 10月 2013
- Offline
Awesome, that totally works. Here's the resulting command:
FWIW I actually ended up bypassing Houdini's HDA system all together and just using saveItemsToFile(). I can then call loadItemsFromFile() to get the nodes back and manage the versioning etc myself.
command = 'otwrite -d -i -l -o %s %s' % (node.path(), filepath) result = hou.hscript(command)
FWIW I actually ended up bypassing Houdini's HDA system all together and just using saveItemsToFile(). I can then call loadItemsFromFile() to get the nodes back and manage the versioning etc myself.
Grant Miller
VFX Supervisor
Ingenuity Studios
VFX Supervisor
Ingenuity Studios
- blented
- Member
- 61 posts
- Joined: 10月 2013
- Offline
Is there by chance an hscript command to set the default of a given parameter?
I looked through http://www.sidefx.com/docs/houdini/commands/opparm.html [www.sidefx.com] and couldn't find anything there, same on the python side of things.
I looked through http://www.sidefx.com/docs/houdini/commands/opparm.html [www.sidefx.com] and couldn't find anything there, same on the python side of things.
Edited by blented - 2019年1月15日 10:30:50
Grant Miller
VFX Supervisor
Ingenuity Studios
VFX Supervisor
Ingenuity Studios
- goldfarb
- スタッフ
- 3464 posts
- Joined: 7月 2005
- Offline
- blented
- Member
- 61 posts
- Joined: 10月 2013
- Offline
Lovely! It doesn't show up under hou.ParmTemplate which makes sense now as not everything has a setDefaultValue.
http://www.sidefx.com/docs/houdini/hom/hou/FloatParmTemplate.html [www.sidefx.com]
Thanks a bunch for the tips
http://www.sidefx.com/docs/houdini/hom/hou/FloatParmTemplate.html [www.sidefx.com]
Thanks a bunch for the tips
Grant Miller
VFX Supervisor
Ingenuity Studios
VFX Supervisor
Ingenuity Studios
- tony_a
- Member
- 86 posts
- Joined: 1月 2009
- Offline
Just in case someone else stumbles across this…or I stumble back across it in the future when I need to do this again. Here's some code that will set the default value of a parameter on a node:
Please note that this only sets it on the instance of the node in your scene, not on the HDA itself.
node_path = '/obj/subnet1' parm_name = 'parm' newDefaultValue = 2.0 #get node n=hou.node(node_path) #get parmTemplateGroup ptg=n.parmTemplateGroup() #get copy of parm in parmTemplateGroup p = ptg.find(parm_name) #set new default value on our copy p.setDefaultValue((newDefaultValue,)) #replace parm in parmTemplateGroup with our copy ptg.replace(ptg.find(parm_name),p) #apply parmTemplateGroup to node n.setParmTemplateGroup(ptg)
- martinkindl83
- Member
- 262 posts
- Joined: 11月 2014
- Offline
- jsmack
- Member
- 8046 posts
- Joined: 9月 2011
- Offline
martinkindl83
Thank you very much for provided info.
Would you know how to change default value for the OTL and not just the scene instance?
instead of setting the node's parmTemplateGroup, set the nodetype's definition's ptg.
node_path = '/obj/subnet1' parm_name = 'parm' newDefaultValue = 2.0 #get node n=hou.node(node_path) # get definition ndef = n.type().definition() #get parmTemplateGroup ptg=ndef.parmTemplateGroup() #get copy of parm in parmTemplateGroup p = ptg.find(parm_name) #set new default value on our copy p.setDefaultValue((newDefaultValue,)) #replace parm in parmTemplateGroup with our copy ptg.replace(ptg.find(parm_name),p) #apply parmTemplateGroup to node ndef.setParmTemplateGroup(ptg)
-
- Quick Links