Detect how many inputs connected to Merge?

   3265   7   0
User Avatar
Member
1007 posts
Joined: April 2017
Offline
Hi!

Is there a way I could connect a detail wrangle just after the merge and pick up how many inputs the merge contains? For example, I can see it matches the amount of cooks. Is there a way to access this value?

Thanks.

-Olivier
User Avatar
Member
900 posts
Joined: Feb. 2016
Offline
You could try this as python expression in integer parm on your merge node.
n = pwd().inputs()
return len(n)

cheers
Edited by Andr - June 16, 2019 11:57:46
User Avatar
Member
1007 posts
Joined: April 2017
Offline
Thanks for the help but I know zero python so I would like to find a Vex solution.

-Olivier
User Avatar
Member
2038 posts
Joined: Sept. 2015
Offline
Just create the int parm as Andr suggested(copy and paste his code) and reference that channel in vex to create your detail attribute?
User Avatar
Member
4 posts
Joined: Dec. 2016
Offline
This is really neat! I reckon it should be accessible by default without extra scripting
User Avatar
Member
8539 posts
Joined: July 2007
Online
msum
This is really neat! I reckon it should be accessible by default without extra scripting
you can use opninputs() [www.sidefx.com] hsript expression, but I guess you could consider that extra scripting too
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
4 posts
Joined: Dec. 2016
Offline
Thanks Tomas! Big fan of your work on this forum

All I meant is that it’s a pretty basic but quite useful variable from that specific node to push it forward, which made me think that it could be just part of it easily accessible without creating additional var and adding just ONE line of code ;D I bet for someone with years of experience it’s just bread and butter, for me it’s still a bit confusing.

So for anyone else looking for a literal way of making it work:

Python:
len(pwd().inputs())

HScript:
opninputs(".")
Edited by msum - June 29, 2021 20:39:23
User Avatar
Member
131 posts
Joined: Aug. 2012
Offline
If such a function is sufficiently useful to you, simply save it as a preset on the node(s) you use. Should note that allowing users the option to customize their workflow as befits their needs is a great boon - one line of code is peanuts

By preset, I mean creating a spare float parameter on Merge node from Edit Parameter Interface, call it inputs/Inputs, typing expression opinputs("."), save as Preset. Could even be a Permanent Default if you wish.
  • Quick Links