Make a button paramater set value to 1 while clicked ?

   1105   5   0
User Avatar
Member
190 posts
Joined: 12月 2016
Offline
Hello, I’m trying to set up a python node that only runs it’s script when a run button is pressed.

The only thing preventing me from making it work is that the button doesn't seem to set a 0 or 1 value for when its pressed.

I’ve tried setting status to 1 using hou.setenv("status",1)
and then read it in the script using hou.getenv("status")

But that didn`t seem to work.
User Avatar
Member
311 posts
Joined: 10月 2016
Offline
Callback script
exec(kwargs.parm('code_py').eval());a()

Multi-line String
name: code_py
content:
def a():
    print('Yes!')
Interested in character concepts, modeling, rigging, and animation. Related tool dev with Py and VEX.
User Avatar
Member
190 posts
Joined: 12月 2016
Offline
Hello,
THis throws me the error
AttributeError: 'dict' object has no attribute 'parm'

I’m also a bit confused, wouldn't I need to use.
('python') if I want to use the normal python script ?




Ps.

I whould think
__import__ (kwargs.parm('python'));main()
whould be the propper formatting ?
Edited by NicTanghe - 2023年1月10日 16:20:45
User Avatar
Member
311 posts
Joined: 10月 2016
Offline
If you just want one or a couple of run buttons and then some python code it is possible to simply attach this to a null. Probably you could attach it to any subnetwork or HDA as well (I've not really been trying this though).

Attachments:
a.png (92.1 KB)
b.png (93.2 KB)

Interested in character concepts, modeling, rigging, and animation. Related tool dev with Py and VEX.
User Avatar
Member
311 posts
Joined: 10月 2016
Offline
If you need to set values accessible from any node, without keeping track of paths to nodes, you could do something like:

def a():
    hou.session.my_value=1

def b():
    hou.session.my_value=0
    
try:
    print(hou.session.my_value)
except:
    pass
Interested in character concepts, modeling, rigging, and animation. Related tool dev with Py and VEX.
User Avatar
Member
190 posts
Joined: 12月 2016
Offline
Hello i didn`t respond yet because I lost 1 month worth of work so I need to catch up for a while
I`ll be back though
  • Quick Links