# RhinoScript find Biggest Z point in array

I’m new to rhinoscript, I started yesterday

Let me try and see if I can explain what I’m doing.

I have a Mesh, from that mesh I need to find the highest point and the lowest point on that mesh.

I started by using the command: MeshVertices and getting a 2D array of all the points in the mesh, so far so good I think.

Now I need to find the Highest Z value of any point (called it “a”) and the lowest Z value of any point (“b”) as integers

so them I can use addpoint(0,0,a) and addpoint(0,0,b) and create a line on the Z axis

My question is how to find a and b, I have no idea.

Hope someone can help me

Hi there,

There is the Rhinoscript Method Rhino.SortPoints,

You can use it to sort an array of Points by their coordinates (using their x,y or z coordinates as the sorting argument),
Using your Point Array and their z-Coordinate as an argument the function will return you an Array of Points where array(0) is the Point with the smallest z coordinate and array(Ubound(array)) is the point with largest z coordinate (or the other way round)

Hope this helps and good luck with learning from another non-pro

K.

Thanks, with some help I found other way that works.
But I think your way would work to.

On to next challenge

If the high/low are aligned with the world axis and you’re not looking for the exact vertex that is the highest or lowest point, but just their Z values, then just use Rhino.BoundingBox on the mesh. That will return the 8 corner points of the world-aligned bounding box in order, the corners 0-3 will be the lower face of the box, and 4-7 the upper. You can then get individual X, Y or Z coordinates from the points. So you could extract the high/low as follows:

``````Dim arrBB
arrBB=Rhino.BoundingBox(mesh)
dblLowZ=arrBB(0)(2)
dblHiZ=arrBB(4)(2)