Jump to content

Dynamic Parameters for Nodes


Recommended Posts

Hi there,

 

I'm currently working on a loader for a custom file format. The file format contains stuff that's similar to digital assets in that it can expose a number of parameters. Therefore I'd like to dynamically add parameters to the Parameter UI of the node every time a new asset file is selected. The parameter definition from the examples seems to be always based on a more or less static definition of an array of PRM_Template. Is there a regular way to dynamically add and remove parameters? I guess I could allocate a PRM_Template array that's large enough to hold a fixed number of extra PRM_Template instances and add or remove elements. This still leaves me wondering at which time Houdini queries this array and (connected) what I can do to force a refresh (e.g. when the file reference and therefore the parameters changed).

 

Anybody done this before or is there an example around that I am missing?

Best

Timm

 

Link to comment
Share on other sites

Hi Edward,

 

thanks for the reply. The problem here is two fold:

 

(1) Strictly speaking I don't know the number and type of parameters beforehand, because they can theoretically vary from object to object. In practice, we currently have a limited set of parameters for which your suggestion will work, though.

(2) More importantly the possible values for some parameters may change. Particularly a few parameters would end up being PRM_ORD with varying choices of parameters in the menu. I am pretty sure this could work (unless the functionality is there but not exposed to the HDK), because I can, on any node, open the Parameter Editor, add an Ordered Menu and specify a menu script instead of fixed menu items.

 

Figuring out 1 would be extremely helpful on the long run but is currently no showstopper. Figuring out 2 would be vital for me.

 

Best

Timm

Link to comment
Share on other sites

Hi Edward,

 

thanks for pointing that thread out, I'll give that a go. As far as I can can see, this answers 1, though. Any thoughts about 2?

 

I did play around a little but with little success. Particularly I tried adding a callback function to a static parameter of type PRM_ORD, but it seems like the callback only got called when the parameter changed, not to set it up. So that seems to be the wrong place to dynamically set the parameter options for the ordinal.

 

I just discovered the SOP_Node::opChanged function which might be a good place to override parameter options, but I am still not sure how to modify them.

 

Thank you so much for all the help you're providing in this forum!

 

Best

Timm

Link to comment
Share on other sites

Sorry, I didn't respond to that because I didn't really understand what you're trying to do. If you just want to have a procedurally generated list of menu items, then you can just provide your own menu callback (via a PRM_ChoiceList) http://www.sidefx.com/docs/hdk14.0/_h_d_k__op_basics__overview__parameters.html#HDK_OpBasics_Overview_Parameters_Menus

  • Like 1
Link to comment
Share on other sites

OK, I almost got it. Using the callback to PRM_ChoiceList works great. The only remaining problem is that I have one parameter (a file reference to an input file), which should trigger the menus of a few other parameters to be rebuilt. When I force a refresh of the parameter ui by selecting another node and then coming back, the updated menus are there, but they don't show right after I changed the file reference. Is there a way to force a UI update from the callback function? I added a callback function to the input file paramter (which is called on parameter change) and hoped I could do it by just returning 1 (which is supposed to trigger some kind of refresh), but that's apparently not enough. I looked through the documentation of PRM_Param and OP_Parameters and tried a few things, but so far had no success. Any pointers on how to jump through this last hoop would be greatly appreciated!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...