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
Link to comment
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
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...