Jump to content

making relative references from hda parms to its children with python


kaffee, junge

Recommended Posts

Hi there,

I am creating folders and parms on an hda with python.
The script looks for a folder name in the hda's children, then creates the same folder with the same (renamed) parms on the hda. 

Now I want to make relative references from the hda to the child parms.

Is there a way to do that by just using the parmTemplates that I already have using the script below?
I dont want to look through each parm on the nodes and match them by name. I think I would need to distinguish between parm and parmTuple and so on...

 

In the script the hda is named test1 with one child node. The child node has a folder called 'Test Folder' containing arbitrary parms.
 

	node = hou.node('/obj/test1')
assetDef = node.type().definition()

##get the first childs parmTemplateGroup and folder by name
parm_group = node.children()[0].parmTemplateGroup()
folder = parm_group.findFolder(('Test Folder'))    ##returns FolderParmTemplate

##get all parms in folder
parm_tuple = folder.parmTemplates()

##create new Folder on the asset
newFolder = assetDef.addParmFolder('Test Folder')

##clone each parm, rename and add to the asset
for item in parm_tuple:
    oldName = item.name()
    clone = item.clone()
    clone.setName('new_' + oldName)
    assetDef.addParmTuple(clone, ('Test Folder',))
	
Edited by cookiemonsterandthegirls
code tags
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...