opinputpath in VEX

   9125   3   1
User Avatar
Member
166 posts
Joined: March 2014
Offline
Hello,

I have the following scenario: I have a node that contains several user parameters. The user will generally copy this node multiple times and change the parameters on each copy.

I now want to use a wrangle node to iterate over all parameters of all copies of this node. My idea was to use a switch node (or maybe a merge?) and let the user plug all his node copies into the switch, then use the wrangle to iterate over all switch inputs.

But how do I do this? The opinputpath is not available in VEX?
User Avatar
Member
166 posts
Joined: March 2014
Offline
I have now added a string parameter to the switch node with the expression:
`opinputpath(“.”, ch(“input”))`

My wrangle node reads this parameter to get the correct path to whichever node the switch is set to. So this works. But I now need to get ALL paths to ALL nodes connected to the switch, not just the currently activated one.

I have little knowledge about expressions, but if it's possible to use loops, it should be possible to get a space separated string with all the paths, right? Can someone help me there?

I'm looking for something like this but with the correct syntax:
string pathList = “”;
for (int i = 0; i < numberOfNodesConnectedToSwitch; i++)
pathList += “ ” + opinputpath(“.”, i);


But I'm thinking there must be an easier way, doing it all within the wrangle?
User Avatar
Member
9538 posts
Joined: July 2007
Offline
that's more job for python than VEX:

import hou
node = hou.node('/obj/geo1/switch1') # your node with multiple inputs
parms =
for input in node.inputs():
if input:
parms += input.parms()

print parms

what exactly you want to do?
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
166 posts
Joined: March 2014
Offline
Thank you, that immediately brought me on the right track and solved my problem. I know Python, and I had just started reading into Houdini's object model. Modifying your script a bit, I've now been able to get the required string into my wrangle node.

It's interesting that you suggest Python, I'm unsure if what I'm doing is possible with it because I haven't looked into it.

I'm constructing a shape grammar. The user starts off with a rectangle. The rectangle has a string attribute called “baseFacade”. The user can then use various nodes to shape this rectangle into something much more complex. Most of this is done by splitting the rectangle into smaller rectangles.

For instance, the user may set up his first node to:
Split “baseFacade” at ratio 0.5 into “groundFloor” and “topFloor”
He may then set up his second node to:
Split “topFloor” into 10 x “windowElement”
and so on and so forth

My SOP network takes all these nodes, reads the parameters and constructs the facade according to the rules specified by the user, making all the required splits, then replacing the elements by actual geometry. I use regular SOP nodes, for each loops and wrangle nodes to do this. So far it's working very well, but I might stumble into issues at some point.
  • Quick Links