Python: add attr to root template folder and switch order

   859   2   1
User Avatar
Member
34 posts
Joined: 9月 2014
Offline
Hi there,


Two things im trying wrap my head around in hom/python.

On a node like a python sop, when you add an attribute manually, it gets added to the root folder?
I can see that entries/ attributes can be stored at root via:
node.parmTemplateGroup().entriesWithoutFolders()

All the code examples i can see, when i add a attribute via python it has to be via a folder.
Is there something im missing?

Secondly, on a switch node, how can i query/ update/ reorder things plugged in via python?

Cheers
Kym
User Avatar
Member
34 posts
Joined: 9月 2014
Offline
so i figured out the switch problem, it looks like its just easier to rebuild the input list from scratch if i want to reorder things.
n.setInput(<input number>, <childnode>)


Still interested in knowing how to add to the root folder for parms on an node.
You can do this by hand in the Parameter interface, but i cant seem to figure this out in python.

Any thoughts?

Cheers
Kym
User Avatar
Member
191 posts
Joined: 10月 2018
Offline
You can use parmTemplateGroup to add/edit the parameters on a node.

node = hou.node('/obj/geo1/null1')

parm_group = node.parmTemplateGroup()
parm = hou.IntParmTemplate("testParm", "Test Parm", 1)
parm_group.append( parm )

node.setParmTemplateGroup( parm_group )
  • Quick Links