Beginner Posted January 14, 2016 Share Posted January 14, 2016 (edited) 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 January 14, 2016 by Beginner Quote Link to comment Share on other sites More sharing options...
f1480187 Posted January 15, 2016 Share Posted January 15, 2016 (edited) 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 January 15, 2016 by f1480187 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.