Jump to content

VEX WRANGLE: For Each attribute @binding?

Recommended Posts

VEX WRANGLE: Is there more efficient/user friendly way to handle attributes with "For each" -statement in vex, than using those that takes string arguments like addattrib, setattrib, attrib.. Now I'm using sprintf to concate my foreach attribute names and then handling attributes with those strings. Would be great to have for each binding e.g.


v@my_`for_each`_attribute = {0,0,0};


Or is there something similar? Thanks!


Example from my code:


string legs[] = {"F_L_","F_R_","M_L_","M_R_","B_L_","B_R_"};


foreach (int leg_num; string leg; legs) 


string leg_pos = sprintf("%s", concat(leg, "pos"));

string leg_ray = sprintf("%s", concat(leg, "ray"));


if( attrib(0, "point", leg_pos, @id) == 0;)


setattrib( geoself(), "point", leg_pos, @id, -1, ray_pos, "set");



Edited by Beginner

Share this post

Link to post
Share on other sites

Nice code, imho. You can use SOP-level For Each and then do exactly what you want by using backticks with expression inside, retrieving detail attribute from metadata node. Why sprintf-ing string into same string, by the way? concat() should work normally there without wrapping. You can also add strings to concatenate them.

str1 + str2 + str3 == concat(str1, str2, str3) == sprintf("%s%s%s", str1, str2, str3)
Edited by f1480187

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account


Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now