python houdini

   4455   3   0
User Avatar
Member
71 posts
Joined: Feb. 2010
Offline
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()
User Avatar
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”
User Avatar
Member
54 posts
Joined: March 2008
Offline
You can use xarchx idea or you can create a otl also , attaching a example otl file.

Attachments:
python_node_op.otl (5.9 KB)

User Avatar
Member
71 posts
Joined: Feb. 2010
Offline
@Xarchx @Achayan
Thank you very much
  • Quick Links