Forgot password?

Create an account!


« back

RhinoScript – Find specific Point in array


Please log in to write a message.

  • 7. quicova (Jul 23, 2013 12.25):

    Thanks Hanno, your a genius, it work!!! I was really struggling with this.

    I will try to learn in the future, but need to finish this thing for tomorrow.
    I never did a script before, but I have a project that really required one.

    Know next challenge, find the coordinates of that point :) but I thinks thats not going to be to hard.

    Thank so much again

  • 6. Hanno (Jul 23, 2013 12.08):

    Ummmm... the "is better than" was a placeholder for an actual test. The computer cannot magically decide what you consider better or worse. Also, you want index 0 in the assignment before the loop. This simply sets the first point as initial "best" point so your loop does not have to compare with Nothing on its first iteration.
    I usually don't write other people's scripts, but here is the snippet:

    bestPoint = arrVertices(0)
    for i = 1 to ubound(arrVertices)
        if arrVertices(i)(2) > bestPoint(2) Then bestPoint = arrVertices(i)

    But if you seriously want to learn how to program, you really should work through some tutorial!

  • 5. quicova (Jul 23, 2013 10.09):

    Hi, thanks for your help, I'm really struggling with this part.

    this is what I have and unfortunately is not working.

            Dim srf, arrVertices
            srf = rhino.GetObject("select Surface")

            arrVertices = Rhino.MeshVertices(srf)
            If IsArray(arrVertices) Then
                    Rhino.AddPointCloud arrVertices
            End If

            Dim bestpoint, i

            bestPoint = arrVertices(2)
            For i = 1 To ubound(arrVertices)
                    If arrVertices(i) Is better than bestPoint Then
                    For Each bestPoint = arrVertices(i)


    I don't get what I'm doing wrong, it gives an error on the "Then"

    Do you have any idea?

  • 4. Hanno (Jul 23, 2013 09.06):


    the pattern in my last reply is still the way to go, the "is better than" part would then be a comparision of Z values (point(2) gives you the Z value), instead of saving the best point you would just save the highest and lowest Z values (btw: I wouldn't call the variables X and Y, that is confusing).

    Do you understand the concept of a for-loop? Otherwise I suggest you read a vbscript tutorial first (see links section, the RhinoScript 101 is a good start).


  • 3. quicova (Jul 22, 2013 23.16):

    Hi Hanno, sorry I didn't got it at all. I'm really new to this.

    I'm trying to find is the highest and lowest number for Z coordinate in all the points in the array.

    So I then can create a point in the Z axis representing the highest point and another point in the Z axis representing the lowest point.

    something like
    p1 = rhino.addpoint(array(0,0,X)
    p2 = rhino.adpoint(array(0,0,Y)

    I just need to find is X and Y and have no ideia how to do it.

  • 2. Hanno (Jul 22, 2013 22.56):


    to find the best match you have to iterate through the points comparing every point to the so far best match:

    bestPoint = points(0)
    for i = 1 to ubound(points)
        if points(i) is better than bestPoint then bestPoint = points(i)

    Hope that helps!


  • 1. quicova (Jul 22, 2013 21.16):

    Hi Everyone,

    I need to find the highest point and the lowest point in a mesh.
    I used Rhino.MeshVertices to get an array of points of the mesh, now I need to find the highest point and the lowest point in that array and do a curve between them.

    anyone has any idea on how to do this?
    Thanks everyone


Why are these buttons gray?