Hi there,
If toggle button =1 then create a node else if toggle button=0 then delete it
the given below is the code I tried.Please let me know the solution.
It works only when the script is run,and the node doesnt get deleted or created after the script is created.
hp=hou.node('/obj').createNode('shopnet','test')
test1=hou.ToggleParmTemplate('a','test1t',1)
hp.addSpareParmTuple(test1,('General test',),True)
toout=hou.node('out').createNode('shopnet','test1')
test2=hou.ToggleParmTemplate('b','test2',1)
toout.addSpareParmTuple(test2,('General test',),True)
test2t=hou.node('out/test1/')
test2t.parm('b').setExpression('ch(“/obj/test/a”)')
if(test2t.evalParm('b')==1):
tout1=hou.node('out').createNode('ifd','mantraworking')
else:
tout11=hou.node('/out/mantraworking')
tou1=hou.node('obj/mantraworking')
tou1.destroy()
python houdini
4778 3 0- omy
- Member
- 71 posts
- Joined: Feb. 2010
- Offline
- xarchx
- Member
- 6 posts
- Joined: June 2011
- Offline
i just tested i hope it would help you
import hou
geo = hou.node(“/obj”).createNode(“shopnet”,“test”)
temp_ = hou.ToggleParmTemplate(“a”,“tested”,0,script_callback=None)
temp_.setTags({“script_callback”: “import hou.session; hou.session.doSome()”,
“script_callback_language”: “python”})
geo.addSpareParmTuple(temp_,('General test',),True)
def doSome():
if geo.evalParm(“a”) == 0:
print “create”
if geo.evalParm(“a”) == 1:
print “delete”
import hou
geo = hou.node(“/obj”).createNode(“shopnet”,“test”)
temp_ = hou.ToggleParmTemplate(“a”,“tested”,0,script_callback=None)
temp_.setTags({“script_callback”: “import hou.session; hou.session.doSome()”,
“script_callback_language”: “python”})
geo.addSpareParmTuple(temp_,('General test',),True)
def doSome():
if geo.evalParm(“a”) == 0:
print “create”
if geo.evalParm(“a”) == 1:
print “delete”
- Achayan
- Member
- 54 posts
- Joined: March 2008
- Offline
- omy
- Member
- 71 posts
- Joined: Feb. 2010
- Offline
-
- Quick Links