vex: how to insert a variable into @attribute_name?

   1269   2   2
User Avatar
Member
24 posts
Joined: April 2020
Offline
Like this:
for (int i=0; i<4; i++)
{
    i@P`i` = i;
}

Im trying to create multiple detail attributes like @P0/@P1/@P2/... Tried multiple expressions but all only output a single @Pi..

Any way to achieve that? Thanks!
Edited by Nuuk - June 6, 2022 07:59:55
User Avatar
Member
43 posts
Joined: Feb. 2017
Offline
for (int i=0; i<4; i++)
{
    string name = "P" + itoa(i);
    setdetailattrib(0, name, i, "set");
    //setdetailattrib(0, name, i);
}

this [www.sidefx.com].
Edited by tachbek - June 6, 2022 07:54:22
User Avatar
Member
900 posts
Joined: Feb. 2016
Offline
Hello, check the attached example file and see if it works for you.

As far as I know the most performant way to dynamically create attributes is to use an Attribute Create inside a feedback loop block.
I never checked python based solution, however.
Edited by Andr - June 6, 2022 08:11:32

Attachments:
attrib_vec_performance.hiplc (151.8 KB)

  • Quick Links