Menu script called multiple times

   3362   6   4
User Avatar
Member
49 posts
Joined: 2月 2016
Offline
Hello!

I am writing a menu script and I notice that it was called multiple times when activated. Is there a way to have it call the menu script once only?

Thanks!

Attachments:
menu_script_error.png (78.4 KB)

User Avatar
Member
7741 posts
Joined: 9月 2011
Online
No, parm scripts execute when the ui thinks it needs to evaluate them, which sometimes causes things like menus to evaluate dozens of times. The only solution is to implement caching for scripts that might be slow, such as disk or database queries.
User Avatar
Member
49 posts
Joined: 2月 2016
Offline
jsmack
No, parm scripts execute when the ui thinks it needs to evaluate them, which sometimes causes things like menus to evaluate dozens of times. The only solution is to implement caching for scripts that might be slow, such as disk or database queries.
That make sense, thanks!
User Avatar
Member
7024 posts
Joined: 7月 2005
Offline
Yes, it's a very longstanding problem that causes a lot of extra dev work unfortunately It would be amazing if it was fixed someday.
User Avatar
Member
22 posts
Joined: 10月 2018
Offline
Is there any update on this?

My menu script is being called 17 times when I select the node.. And I have another menu script that evaluates the first one so combined they get called 64 times…..!

I'm going to try and timestamp the call and only allow another call to the function after one second but we shouldn't have to do that..
User Avatar
Member
49 posts
Joined: 2月 2016
Offline
mike.battcock
Is there any update on this?

My menu script is being called 17 times when I select the node.. And I have another menu script that evaluates the first one so combined they get called 64 times…..!

I'm going to try and timestamp the call and only allow another call to the function after one second but we shouldn't have to do that..
If you still getting the problem then it probably was't fixed yet. Maybe you can report it as a bug.
User Avatar
Member
900 posts
Joined: 2月 2016
Offline
The other problem is that each menus script is evaluated (6 times) on ANY parameter changes of the node.

Anyway it's not a “bug”. I contacted the support team few days ago for the same concern, I was told the following:

Multi calls are expected because the results of evaluated parameter scripts and expressions are never cached and typically there are are a few different components in Houdini that are interested in the parameter's menu entries.

This make the menu script not advisable to be used in an instance of a multiparm folder.
For example, my scenario was the following:
Need to use 4 different Menu Scripts inside a multiparm block list.
Each Menu Script performs a 3 cycles for-loop with some basic paramater evaluation.
On average I have 25 multiparm istances.
Math says that at each parameter change of my digital asset I would trigger 4(menu scripts) * 3(loop-cycles) * 25(instances) * 6(times) = 1800 (!!) loop cycles.
Edited by Andr - 2019年9月16日 03:37:30
  • Quick Links