Add or edit digital asset parameters via Python?

   4213   4   4
User Avatar
Member
20 posts
Joined: Oct. 2016
Offline
Hi everyone,

I am trying to add and edit digital asset parameters in Python and can't figure out two things:
Is there a way to add parameters to digital assets via Python?
Also, is it possible to edit the ‘linked channels’ options for parameters already inside the asset in Python?

Thanks,
Rok

Rok Andic
www.rokandic.com
User Avatar
Staff
3455 posts
Joined: July 2005
Offline
the basic method is to:
make a copy of the asset's parmTemplateGroup - https://www.sidefx.com/docs/houdini/hom/hou/ParmTemplateGroup.html [www.sidefx.com]
then add/edit/remove templates (folders/parms etc)
then you set the asset's parmTemplateGroup using setParmTemplateGroup


example:
say you have an asset called foo.hda

asset = hou.node('/obj/foo')
ptg = asset.parmTemplateGroup() # make a copy of the parmTemplateGroup
folder = hou.FolderParmTemplate("test", "Test") # create a folder template
folder.addParmTemplate(hou.FloatParmTemplate("test", "Test", 3, default_value=(0.0,))) # create a float template inside the folder
ptg.addParmTemplate(folder) # add the folder template to the copy of the parmTemplateGroup
asset.setParmTemplateGroup(ptg) # set the asset to use the new parmTemplateGroup
Michael Goldfarb | www.odforce.net
Training Lead
SideFX
www.sidefx.com
User Avatar
Member
20 posts
Joined: Oct. 2016
Offline
Thank you very much for your help Michael.

About the linked channels. I was renaming some attributes via Python and I thought I made a mistake because all ‘linked channels’ were lost. But they were lost because the nodes were still referencing the old name parameter. Once I corrected the expression to point to the new name everything is linked correctly.

Works great now, thanks

Rok Andic
www.rokandic.com
User Avatar
Member
94 posts
Joined: Nov. 2017
Offline
Michael,

unfortunately _I can't get this to work on an HDA if I want to replace/alter a parmTemplate. In my case I clone the chosen parm template, alter its menu_names and menu_labels, and try to use

parmGroup.replace(currentParm, clonedParm)
rig.setParmTemplateGRoup(parmGroup)

Unfortunately this doesn't change anything. No error message, but the values stay the same.

Any idea how to do this? Since I need to change a lot of entries, doing this manually isn't a real option. Manually I would “enter” the node via the “type properties”. Is that the reason why replace fails? Or is my syntax wrong in a way?

Cheers
Tom
User Avatar
Member
94 posts
Joined: Nov. 2017
Offline
Got it solved.

On HDA the syntax needs to be different. No idea where in the docs this is mentioned.

READING: rig.type().definition().parmTemplateGroup(params)

WRITING: rig.type().definition().setParmTemplateGroup(params)

Inbetween everything should be like in the regular parmTemplate workflow. Just type().definition() makes the whole difference.
  • Quick Links