VEX Code Access "Group" Parameter

   491   1   2
User Avatar
Member
1 posts
Joined: Jan. 2017
Offline
Hello Guys,

I am trying to print point position information based on the points I set in the group parameter.

but I can't loop over the @ptnum, I also tried to use an increment variable, but it's always the same.


here's the snippet:


can anyone help on how to get the input from group parameter in vex, something like
int pts[] = [ 3, 4, 2, 0]

cheers.
Edited by ndickson - Feb. 9, 2018 09:28:10

Attachments:
2018-02-09_16h20_10.png (15.0 KB)

User Avatar
Staff
1653 posts
Joined: March 2012
Offline
There's the expandpointgroup [www.sidefx.com] VEX function, e.g.

int points[] = expandpointgroup(0, chs("group"));
int n = len(points);
for (int i = 0; i < n; ++i) {
    int pt = points[i];
    ...
}

However, it's important to note that you'll need to do this with “Run Over” set to “Detail (Only Once)”; in that case, the node won't use the Group field for its own iteration, since it will run only once. What's happening in the snippet you posted is that VEX effectively runs the code snippet independently for each point, so each one creates a new variable i, sets it to zero, then prints that out.

Hopefully that helps out.
  • Quick Links