pressButton, onLoaded event

   1161   4   2
User Avatar
Member
15 posts
Joined: March 2015
Offline
Hi all,
Is there a way to have a callback trigger, when added in an onLoaded event in an HDA?

Currently I am registering my callback (addParmCallback) in the onloaded event in my hda, that is in my scene. When I open a the scene that has the hda, the callback gets registered, and this works as expected.
The called function builds a path that depends on certain shot variabls and I want it to be triggered when a user opens up a scene in a different shot. This is unfortunaley not happening.
I tried using the pressButton() method to trigger the event, which works in the shell but not when called in the onLoaded event.

Im not sure if this is what is meant to happen and I am just doing the wrong thing, or if its a bug and the pressButton should work...

anyhelp on getting this working would be much appreciated...

PS
added a simple example below
Edited by Roger Wellard - Aug. 25, 2022 07:30:16

Attachments:
example_hda.1.0.hda (11.6 KB)
example.hip (57.3 KB)

User Avatar
Member
53 posts
Joined: Feb. 2017
Offline
Can you explain which function you want to trigger when? Do you want to trigger the change_string() function when a user puts a new instance of the node down or only on first loading of the scene? In the trigger_callback() function you are also using the .pressButton() function while that parameter is not of button type. I might just not understand well what you want to do?
Technical VFX artist @ Housemarque / Sony Interactive Entertainment
User Avatar
Member
15 posts
Joined: March 2015
Offline
Thanks for your reply...

In my simplified example,
I would like like the trigger_callback function to run, which it appears to do. The console prints the print statement in the function,however the pressButton() function does not run...or it least it does and the result is not what I would expect.
The pressButton() function name is a little misleading. You can use the pressButton function to trigger a callback regardless of the paramater type.
In the console I am able to run:
hou.parm('/obj/example_hda1/changeme').pressButton()
and trigger the callback, which is the same thing that I am doing in the onLoaded event....

hope I am making a little more sense now.....
Edited by Roger Wellard - Aug. 25, 2022 09:49:42
User Avatar
Member
53 posts
Joined: Feb. 2017
Offline
Change your callback to OnCreated and it seems to do what I understand you want to do? It gives the same trigger as I get when running the command you pasted here in the console. Again, I am not 100% sure I understand you correctly but oh well
Technical VFX artist @ Housemarque / Sony Interactive Entertainment
User Avatar
Member
15 posts
Joined: March 2015
Offline
yeah its wierd that it will run when in the onCreated event and not on the onLoaded event.
In our production version of the example hda we have it in the onCreated event, but I was hoping to have it working in the onLoaded event so that if a scene that has the hda gets saved and then opened in another shot, the paths would be build without them having delete the old node and create a new one.

Not sure if this is a bug or I am expecting somthing that is not possible

appreciate the help...
Edited by Roger Wellard - Aug. 25, 2022 10:43:17
  • Quick Links