access attribute value from string

   2528   3   1
User Avatar
Member
30 posts
Joined: Sept. 2017
Offline
I use a group expression node to create a group that has density greater than .5.
@density > 0.5

From a menu I select the attribute 'pressure'. I would like the group expression to reference the menu item and change the group expression to @pressure > 0.5.

I tried @'...relative path to menu selection' > 0.5

I tried a few things to try to reference the string name of the selected attribute and use it in a vex expression. I assume this is easy and I am missing something obvious, but right now I can't figure it out.
User Avatar
Member
30 posts
Joined: Sept. 2017
Offline
I add this to a node's parameters

from itertools import chain

node = hou.pwd()
geo = node.geometry()
attribs =

return list(chain(*zip(attribs, attribs)))


I now have a menu with all of the point attributes from the Geometry spreadsheet, listed with an @. For example I can select "@pressure".

If I copy parameter and paste relative reference, I get something like the following
'chs("../scaleData/menuItem")'
This string is "@pressure".
In vex if I enter @pressure in an expression, the pressure value for a point will be loaded.
If I place a reference to a string, vex will say invalid source.

Any suggestions? Ultimately, I just want the user to select what attribute to visualize.
User Avatar
Member
9378 posts
Joined: July 2007
Online
Inserting Hscript expression should work as that's expanded before vex is compiled
However maybe better solution would be to use bindings tab on wrangle to bind your vex variable to any attribute you want
Tomas Slancik
CG Supervisor
Framestore, NY
User Avatar
Member
30 posts
Joined: Sept. 2017
Offline
I have not used the bindings tab in the Attribute Wrangle.
Thanks for the great suggestion.

I figured out how this works and will use it in the future.

But, I am having trouble referencing the parameter from the menu selection.

I tried copying the menu item parameter. `chs("../null1/point_attribs")`
I then pasted relative reference to "Attribute Name" in the bindings tab.
I get "Bad parameter reference". But if I typing pressure and a VEX parameter, I can use the Vex Parameter in my vex expressions.
  • Quick Links