Jump to content

VEX: get attribute values into an array


JJ FX

Recommended Posts

Hi,

I have this piece of code

float scale[];
for (int i=0; i<@numpt; i++) {
    float size = point(geoself(), "area", @ptnum);
    scale[i] = size;
}

f[]@testing = scale;

Which gives me an array of the same value for each point. So:

0: [12,12,12,12....]

1: [4,4,4,4....]

2: [67,67,67,67...]

....

What I want is an exact array for each of the points from @area.

This way when I sort the array, I can get the biggest value, and therefore keep only the biggest object (because Im using packed geometry)

 

EDIT: I know I can just sort with sort SOP by attrib. But just trying to uderstand and learn VEX and wrangles better

Edited by JJ FX
Link to comment
Share on other sites

21 hours ago, JJ FX said:

Hi,

I have this piece of code


float scale[];
for (int i=0; i<@numpt; i++) {
    float size = point(geoself(), "area", @ptnum);
    scale[i] = size;
}

f[]@testing = scale;

Which gives me an array of the same value for each point. So:

0: [12,12,12,12....]

1: [4,4,4,4....]

2: [67,67,67,67...]

....

What I want is an exact array for each of the points from @area.

This way when I sort the array, I can get the biggest value, and therefore keep only the biggest object (because Im using packed geometry)

 

EDIT: I know I can just sort with sort SOP by attrib. But just trying to uderstand and learn VEX and wrangles better

Do you run this wrangle in Detail Mode ? I'm pretty sure not if you can access to the @ptnum variable...

Link to comment
Share on other sites

18 minutes ago, fsimerey said:

Do you run this wrangle in Detail Mode ? I'm pretty sure not if you can access to the @ptnum variable...

If one wants to run it in Detail mode, one should indeed use the npoints(0) function that returns the number of points of the first stream of geo incoming in the Wrangle node.

That being said, I don't see the point of running that code on Points, as it basically process the same thing npoints times :-)

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...