Hi!
I used a copy-to-point to distribute a line (2 points per line) on a curve and I would like to select all the lowest points of each primitive so I can snap them to the ground.
Is this a for-each thing?
Thanks.
-Olivier
VEX: Select lowest point (Y) of each primitive?
8437 6 2- olivierth
- Member
- 1002 posts
- Joined: April 2017
- Offline
- jsmack
- Member
- 7613 posts
- Joined: Sept. 2011
- Offline
In an attrib vop/wrangle running over primitives, you can loop over the points in the current primitive (there is a function that returns an array of points associated with a primitive number) and in the loop find the point with the lowest y coordinate. This would work in the most general case.
In your case, you can probably assume some facts about the input. Maybe you know that the point with no neighbors is always the lowest point. Maybe you can assume that the last/first vertex of the line is the lowest point. In these cases, there is no need to loop over all of the points.
In your case, you can probably assume some facts about the input. Maybe you know that the point with no neighbors is always the lowest point. Maybe you can assume that the last/first vertex of the line is the lowest point. In these cases, there is no need to loop over all of the points.
- goldfarb
- Staff
- 3455 posts
- Joined: July 2005
- Offline
- bonsak
- Member
- 459 posts
- Joined: Oct. 2011
- Offline
Before you copy the line to the points, give the last point of the line an attribute that you can access later, like “last_point=1”
Or you can use the bounding box to find the position of the lowest point in a wrangle like this:
And then set a threshold of 0.001.
-b
Or you can use the bounding box to find the position of the lowest point in a wrangle like this:
vector min; vector max; getbbox(0, min, max); float y_component = min.y; if(@P.y < y_component + chf('Threshold') && @P.y > y_component - chf('Threshold')){ @a = 1; }
-b
- vusta
- Member
- 555 posts
- Joined: Feb. 2017
- Offline
- olivierth
- Member
- 1002 posts
- Joined: April 2017
- Offline
- papsphilip
- Member
- 375 posts
- Joined: July 2018
- Offline
jsmack
In an attrib vop/wrangle running over primitives, you can loop over the points in the current primitive (there is a function that returns an array of points associated with a primitive number) and in the loop find the point with the lowest y coordinate. This would work in the most general case.
In your case, you can probably assume some facts about the input. Maybe you know that the point with no neighbors is always the lowest point. Maybe you can assume that the last/first vertex of the line is the lowest point. In these cases, there is no need to loop over all of the points.
what if i want to run over primitives with the same name attribute and then access their points? run over grids made of primitives
Edited by papsphilip - Sept. 22, 2019 06:39:16
-
- Quick Links