Finding the minimum and maximum values of an attribute (VEX)
Example: Knowing the minimum and maximum values of an attribute can be helpful in a situation where you want to remap the attribute with a fit() or efit() VEX function.
This can be useful if you need to fit attributes in the middle of a vex script. Creating attribute arrays can get heavy and slow so in most cases it’s better to use this method of promoting attribute min and max values to detail: Procedural Attribute Remap
Logic around the script:
Run over points
read the values of the attribute with a for loop that iterates over all the points of the input stream
append the value to an array consisting of all the values of the attribute
read the minimum and maximum values of the array with min() and max() VEX functions
store the minimum and maximum values to variables or point attributes depending on the need.
Script:
float value; float values[]; string attrname = "name"; float max_value; float min_value; for (int i=0; i<@numpt; i++){ value = point(geoself(), attrname, i); append(values,value); } min_value = min(values); max_value = max(values);