Extract the minimum and maximum values out of any node
1084 8 3- proceduralist
- Member
- 202 posts
- Joined: May 2021
- Offline
How can I extract the minimum and maximum values out of any node? Here I want to evaluate the maximum and minimum values measured by the 'distance node' and experiment further.
I have to manually go to geometry spreadsheet and find out the minimum and maximum values. Is there a more efficient way to do it?
I have to manually go to geometry spreadsheet and find out the minimum and maximum values. Is there a more efficient way to do it?
- bollili
- Member
- 211 posts
- Joined: Dec. 2009
- Offline
- proceduralist
- Member
- 202 posts
- Joined: May 2021
- Offline
Thanks. How do I work with that inside a VOP network? I need those values for doing fit range while specifying min and max. I end up doing manually by sorting the values from highest to lowest in the geo spreadsheet.
Also, if I am working with only points, without promoting the attribute to primitive, the attribute promote throws up an error because of source and target geometry being identical.
Also, if I am working with only points, without promoting the attribute to primitive, the attribute promote throws up an error because of source and target geometry being identical.
- Mohanpugaz
- Member
- 146 posts
- Joined: June 2016
- Offline
I think that is not straight forward inside of vops.
Two ideas i have.
1. you may use vex snippet to
iterate through all points and find maximum value. (You could also use for loop in vops)
2. You may store that value to a list/array, sort the array and get the last or first index.
Example here. You will Need to alter it to use inside vops.
Two ideas i have.
1. you may use vex snippet to
iterate through all points and find maximum value. (You could also use for loop in vops)
2. You may store that value to a list/array, sort the array and get the last or first index.
Example here. You will Need to alter it to use inside vops.
int npts = @numpt;
float test_values[];
for (int i = 0; i < npts; i++) {
append(test_values, point(0, "test", i));
}
sort(test_values);
float max_value = test_values[-1];
Edited by Mohanpugaz - June 13, 2024 12:39:32
Mohan Pugaz
movfx
https://www.instagram.com/movfx/ [www.instagram.com]
https://www.youtube.com/channel/@_movfx
movfx
https://www.instagram.com/movfx/ [www.instagram.com]
https://www.youtube.com/channel/@_movfx
- bollili
- Member
- 211 posts
- Joined: Dec. 2009
- Offline
You could have look at set attribute vop. https://www.sidefx.com/docs/houdini/nodes/vop/setattrib.html [www.sidefx.com]
I never used it, though.
I never used it, though.
- pixelninja
- Member
- 45 posts
- Joined: March 2017
- Offline
- proceduralist
- Member
- 202 posts
- Joined: May 2021
- Offline
pixelninja
Before your VOP you'll need two attribute promote SOPs to get detail attributes for the minimum and maximum of the attribute.
Then in your VOP you reference those detail attributes with a get attribute VOP.
Thanks! This is a very useful method. As I am only working with points, I first promoted the attribute to detail, then promoted back to point.
However, instead of giving out value with a single number (which is my requirement), it is giving the same value multiple times, (as it is promoting the value on all the points).
I think that's what causing issue here. Based on the minimum and maximum distances, I want to move the points in Y direction. What to do now?
- proceduralist
- Member
- 202 posts
- Joined: May 2021
- Offline
Mohanpugaz
I think that is not straight forward inside of vops.
Two ideas i have.
1. you may use vex snippet to
iterate through all points and find maximum value. (You could also use for loop in vops)
2. You may store that value to a list/array, sort the array and get the last or first index.
Example here. You will Need to alter it to use inside vops.int npts = @numpt;
float test_values[];
for (int i = 0; i < npts; i++) {
append(test_values, point(0, "test", i));
}
sort(test_values);
float max_value = test_values[-1];
I am not good at VEX. I don't understand this code except for the first line in which you created an integer attribute named 'npts' which is equal to the number of points.
- pixelninja
- Member
- 45 posts
- Joined: March 2017
- Offline
You have "delete original" checked on your attribute promotes so they are deleting your dist attribute.
Look at the parameters in the screenshot I sent and you'll see that is unchecked.
There's also no need to promote back to points. The purpose of a detail attribute is to have a uniform attribute value accessible by the whole geometry.
You promote your attributes to detail as shown in my previous post then read them into VOPs with get attribute nodes.
When you're reading attributes into VOPs you use a Bind VOP for reading attributes from the current geometry type (points in your case) and a Get Attribute VOP for reading attributes from other types (vertex, prim or detail in this case).
Look at the parameters in the screenshot I sent and you'll see that is unchecked.
There's also no need to promote back to points. The purpose of a detail attribute is to have a uniform attribute value accessible by the whole geometry.
You promote your attributes to detail as shown in my previous post then read them into VOPs with get attribute nodes.
When you're reading attributes into VOPs you use a Bind VOP for reading attributes from the current geometry type (points in your case) and a Get Attribute VOP for reading attributes from other types (vertex, prim or detail in this case).
-
- Quick Links