folder radio buttons callback script

   7066   7   2
User Avatar
Member
277 posts
Joined: 7月 2006
オフライン
Hi!

Is there any method to call callback script after switching tab of a “radio button folders” in HDA?

Thank you
User Avatar
Member
1925 posts
Joined: 11月 2006
オフライン
There is no direct way to do it, but attached is a hack that mimics it.

I have a set of radio button folders with the parm tuple name “radios” (they could be any type) and you can change them as you will. I also have an integer parm that channel references the first folder in the group “radios1”. Attached to that I have a callback that merely prints the new folder index value. When the folder changes, the parameter then changes and executes is callback script which you could do whatever you wanted then. Since it's just for calling back you should probably hide it.

Attachments:
fake_folder_change_callback.hipnc (38.9 KB)

Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
277 posts
Joined: 7月 2006
オフライン
woow that is great!
Thank you so much!

Could you only explain to me, why when I have script ch(“radios1”)
it changes while changing tabs? I have thought that radios1 is the first tab and it could be 0 or 1 if the tab is selected or no ?
User Avatar
Member
1925 posts
Joined: 11月 2006
オフライン
I'm not really sure why. Trying to access folder information has always been kind of strange and unreliable. I believe trying to ch(“radios”) doesn't work because radios is actually the group of folders and you can't actually evaluate it. That's why you need to access the first folder directly. Unfortunately I don't have a much better explanation. I really hate scripting access to folders
Graham Thompson, Technical Artist @ Rockstar Games
User Avatar
Member
277 posts
Joined: 7月 2006
オフライン
Thank you graham

I hate it too and hope that it would be better in houdini 11
User Avatar
Member
8077 posts
Joined: 7月 2005
オフライン
graham
I'm not really sure why. Trying to access folder information has always been kind of strange and unreliable. I believe trying to ch(“radios”) doesn't work because radios is actually the group of folders and you can't actually evaluate it.

It can't work because “radios” is a parameter name and ch() requires a channel name. ie. For the same reason that you need to use ch(“tx”) isntead of ch(“t”).
User Avatar
Member
277 posts
Joined: 7月 2006
オフライン
Thank you

And could you explain, why when I have script ch(“radios1”)
it changes while changing tabs?
User Avatar
Member
6 posts
Joined: 11月 2018
オフライン
Hello,

This is a bit old but I think the idea might still be usefull in specific cases. One way to achieve this goal via a workaround would be to use python code and set the folder type to radio buttons.

The idea is to set all tabs parms callback as usual (before setting them as radio buttons) aside from the root folder callback that contains a code similar to the one below:
eval(retrieve_python_callback_string_function(root_folder_callback_string, **kwargs))

As we are using the root folder callback input parm with the previous python code, we need to ensure that we provide a root_folder_callback_string that would be returned by our function when the root folder tab will be the one selected.

Then your "retrieve_python_callback_string_function" either return the root_folder_callback_string when kwargs.eval() result is 0.
if kwargs['parm'].eval() == 0:
    return root_folder_callback_string

Or returns the current selected tab callback's script string by returning the folowing commands.

else:
    parm_template_tags = kwargs['parm'].parmTemplate().tags()
    return parm_template_tags["script_callback:{}".format(kwargs['parm'].evalAsString())]

For sure you could code this function as a one line python code directly in the root folder callback input, but I found using a function for that cleaner.

the complete code would look like that:

def retrieve_python_callback_string_function(root_folder_callback_string, **kwargs):

    if kwargs['parm'].eval() == 0:
        return root_folder_callback_string
    else:
        parm_template_tags = kwargs['parm'].parmTemplate().tags()
        return parm_template_tags["script_callback:{}".format(kwargs['parm'].evalAsString())

Hope this helps

Logan Schwartz, Fx TD @Cinesite Montreal
Edited by logan169 - 2021年5月28日 12:08:13
  • Quick Links