VEX: Select lowest point (Y) of each primitive?

   8568   6   3
User Avatar
Member
1007 posts
Joined: April 2017
Offline
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

Attachments:
get_lowest_point_per_prim.JPG (21.0 KB)

User Avatar
Member
7762 posts
Joined: Sept. 2011
Online
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.
User Avatar
Staff
3455 posts
Joined: July 2005
Offline
doesn't answer your question but…
when building procedural things it's very handy to use groups - in this case groups on your line before its copied would allow you to do stuff to the group after…
Michael Goldfarb | www.odforce.net
Training Lead
SideFX
www.sidefx.com
User Avatar
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:
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;
}
And then set a threshold of 0.001.

-b
http://www.racecar.no [www.racecar.no]
User Avatar
Member
555 posts
Joined: Feb. 2017
Offline
not VEX.. but just a proof of concept
Edited by vusta - March 2, 2018 16:36:51

Attachments:
BottomToGround.hipnc (67.3 KB)

User Avatar
Member
1007 posts
Joined: April 2017
Offline
Ahh! ok ok.

The idea of making a group before making copies or, simply using a group range and selecting every 2 would work nicely!

I'll try to do the vex(primitive) thing also, just to understand it more.

Thanks for all the ideas. I learn stuff every day!

-Olivier
User Avatar
Member
385 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