how to reset multiple simulations with 1 button?

   4173   17   3
User Avatar
Member
13 posts
Joined: March 2020
Offline
I am trying to create a HDA with a few pop and dop simulations that will need to be reset after the user change the seed, and wonder what is the way to link all the reset simulation buttons to 1 master button on the HDA interface?
Edited by LH21 - March 2, 2021 20:38:56
User Avatar
Member
191 posts
Joined: Oct. 2018
Offline
You could add a callback script to the seed parameter so that when it's changed it does a pressButton() on all the dopnet's reset simulation buttons. Depending how heavy the inputs to these sims, that might not be a good idea though if it takes time to calculate the source like high res grains or something.
User Avatar
Member
13 posts
Joined: March 2020
Offline
I understand the concept, but I have no experiences with python, would you be able to show me how that script would look like?
User Avatar
Member
191 posts
Joined: Oct. 2018
Offline
In the Scripts tab of the HDA, make a new Python Module event handler from the drop down list on the lower left, then make a function that's something like this:

def resetSimulations():
    parent = hou.pwd() # This gets the current HDA node
    
    # Specify the DOP network names in a list
    # If you have nested DOP networks, specify the relative
    # path to the HDA like "subnet1/popnet1"
    networks = [ "popnet1", "dopnet1" ]
    
    # Loop over DOP networks
    for net in networks :
        node = hou.node( parent.path() + "/" + net ) # Get current DOP network node
        button = node.parm("resimulate") # Get the Reset Simulation button
        button.pressButton()

Then on your parameter's Callback Script put this in there and make sure it's set to Python:
hou.phm()resetSimulations()
Edited by krueger - March 4, 2021 17:06:57
User Avatar
Member
13 posts
Joined: March 2020
Offline
Thanks for the help, and the explanations, but I got this error whenever I click the master button on the interface

SyntaxError: ('invalid syntax', ('Object/bombexpl_fx/resetsim', 1, 25, 'hou.phm()resetSimulations()\n'))


the name of my master button is resetsim
User Avatar
Member
191 posts
Joined: Oct. 2018
Offline
louiehoi
Thanks for the help, and the explanations, but I got this error whenever I click the master button on the interface

SyntaxError: ('invalid syntax', ('Object/bombexpl_fx/resetsim', 1, 25, 'hou.phm()resetSimulations()\n'))


the name of my master button is resetsim

My bad, there should be a period in there after phm()

hou.phm().resetSimulations()
User Avatar
Member
13 posts
Joined: March 2020
Offline
more error message returning

Traceback (most recent call last):
  File "Object/bombexpl_fx/resetsim", line 1, in <module>
  File "Object/bombexpl_fx, PythonModule", line 12, in resetSimulations
AttributeError: 'NoneType' object has no attribute 'parm'



this looks very similar to the one I tried earlier from this post

https://www.sidefx.com/forum/topic/56734/?page=1#post-254147 [www.sidefx.com]

also returns the no attribute 'parm'
User Avatar
Member
191 posts
Joined: Oct. 2018
Offline
It's not pointing to your dopnet correctly. Can you post your python script and also the paths to your dopnets?
User Avatar
Member
13 posts
Joined: March 2020
Offline
def resetSimulations():
    parent = hou.pwd()
    
    networks = [ "obj/bombexpl/bombexpl/popnet10", "obj/bombexpl/bombexpl/popnet112" ]
    
    for net in networks :
        node = hou.node( parent.path() + "/" + net )
        button = node.parm("resimulate")
        button.pressButton()
User Avatar
Member
191 posts
Joined: Oct. 2018
Offline
The entries in your networks list should be relative to your HDA and not absolute paths because your HDA path will most likely change. That's why you get the parent path and then add the relative dopnet path to it.

This is currently going to evaluate as something like this:
/obj/whatever_your_HDA_is/obj/bombexpl/bombexpl/popnet10

So trim off the HDA path in your network list entries so it's either "bombexpl/popnet10" or just "popnet10" (I can't tell if you've got it nested inside a node called "bombexpl" inside your HDA)
User Avatar
Member
13 posts
Joined: March 2020
Offline
oh yes it worked, thanks for help!
User Avatar
Member
191 posts
Joined: Oct. 2018
Offline
No problem
User Avatar
Member
8554 posts
Joined: July 2007
Online
You can also RMB/Copy Parameter on your hda button
and RMB/Paste relative references on all the Reset Simulation buttons on your dopnets

Then clicking button in hda would trigger all buttons that reference it
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
13 posts
Joined: March 2020
Offline
tamte
You can also RMB/Copy Parameter on your hda button
and RMB/Paste relative references on all the Reset Simulation buttons on your dopnets

Then clicking button in hda would trigger all buttons that reference it


Tried this at the start, but the reset simulation button on the dopnet never turned green and get linked together.
User Avatar
Member
8554 posts
Joined: July 2007
Online
louiehoi
Tried this at the start, but the reset simulation button on the dopnet never turned green and get linked together.
I'm pretty sure it used to work, if not you can also
- open Type Properties for your HDA
- in Parameters tab select your button
- go to Channels Tab
- and drag all your buttons into the Add Links area for dropping
- press Apply or Accept
- all those buttons will link to your HDA button, and while they will not turn green their text should be bold and if you RMB/Expression/Edit Expression on any of them you should see the reference
Edited by tamte - March 5, 2021 20:35:09
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
13 posts
Joined: March 2020
Offline
tamte
louiehoi
Tried this at the start, but the reset simulation button on the dopnet never turned green and get linked together.
I'm pretty sure it used to work, if not you can also
- open Type Properties for your HDA
- in Parameters tab select your button
- go to Channels Tab
- and drag all your buttons into the Add Links area for dropping
- press Apply or Accept
- all those buttons will link to your HDA button, and while they will not turn green their text should be bold and if you RMB/Expression/Edit Expression on any of them you should see the reference


Thanks for this, definitely a faster and easier way to do it!
User Avatar
Member
1 posts
Joined: Nov. 2021
Offline
tamte
louiehoi
Tried this at the start, but the reset simulation button on the dopnet never turned green and get linked together.
I'm pretty sure it used to work, if not you can also
- open Type Properties for your HDA
- in Parameters tab select your button
- go to Channels Tab
- and drag all your buttons into the Add Links area for dropping
- press Apply or Accept
- all those buttons will link to your HDA button, and while they will not turn green their text should be bold and if you RMB/Expression/Edit Expression on any of them you should see the reference


Hi! Does this still work? Because i can't do it.
User Avatar
Member
1 posts
Joined: Nov. 2017
Offline
darkkonee6
tamte
louiehoi
Tried this at the start, but the reset simulation button on the dopnet never turned green and get linked together.
I'm pretty sure it used to work, if not you can also
- open Type Properties for your HDA
- in Parameters tab select your button
- go to Channels Tab
- and drag all your buttons into the Add Links area for dropping
- press Apply or Accept
- all those buttons will link to your HDA button, and while they will not turn green their text should be bold and if you RMB/Expression/Edit Expression on any of them you should see the reference


Hi! Does this still work? Because i can't do it.


Hello, I just found this thread helpful. I was not able to drag and drop anymore - not sure if that's my fault though. However if you type in (or copy text and paste) the link of the destination channel into the Linked Channels field, it still works as expected. Text was bolded on my buttons, and I can see the reference at RMB > Exression > Edit Expression. Perhaps I dragged wrong, but for anyone trying, this was my simple solution - type it.
  • Quick Links