Dynamic number of inputs in an HDA

   1557   3   0
User Avatar
Member
11 posts
Joined: March 2020
Offline
Hi all - have been digging around for this and haven’t been able to find an answer. I’m building an HDA in LOP’s with render layer functionality where I would like to tie the number of inputs to a parameter (like a multiparm block where the user can easily add more).

The HDA is structured in a way where each input renders out as a separate EXR (very useful for splitting out elements for comp, or rendering multiple variations). In some instances like rendering 7 variations it would be great to dynamically add more input slots on the node - without permanently cluttering the node with a ton of inputs when not needed. Curious if anyone has done this before.

Cheers!
User Avatar
Member
243 posts
Joined: May 2017
Offline
Hey,
you can dynamically change the number of HDA inputs, but it is a property of a node type and not of a node instance, which would mean that if you call two instances of this node type and dynamically adjust their number of inputs, the change would affect both or generally all instances at the same time.

Here is an example:

# HDA/Scripts/OnInputChanged
n = kwargs["node"]
nt = n.type()
ntd = nt.definition()
input_cnt = len(n.inputConnections())
ntd.setMaxNumInputs(input_cnt + 1)
Edited by vikus - Nov. 20, 2023 15:28:16

Attachments:
dynamic_hda_inputs.gif (344.5 KB)

User Avatar
Member
9281 posts
Joined: July 2007
Online
tomteller
- without permanently cluttering the node with a ton of inputs when not needed
just set your number of inputs to maximum you thing you will need
as long as you have the Max Inputs set to at least 28 there is no clutter as they appear like a single line like in Merge SOP

I wouldn't advise to dynamically change the HDA definition as that's usually in an external file and can be shared across many setups so any alteration may break scenes using instances of that definition
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
11 posts
Joined: March 2020
Offline
Ah, thanks guys! Really appreciate both of these approaches.
  • Quick Links