Better way to Access Rhino.IndexPair Infomation in Python?


(Matt Gaydon) #1

Couple of questions…

Firstly note this is in a Grasshopper Python Component so the List management is somewhat controlled by Grasshopper.

  1. Is there a better way than this, to access Index Pair in Python. so it stays as a list and i don’t have to duplicate code.

  2. Also i am getting an issue when trying to access vertex colours as it wants a Array[Object] but my index is a Array[int].

    import Rhino.IndexPair as ip

    pi = mesh.TopologyEdges.GetTopologyVertices(i)

    i_p= ip.I.GetValue(pi)
    j_p= ip.J.GetValue(pi)

    iv0 = mesh.TopologyVertices.MeshVertexIndices(i_p)
    iv1 = mesh.TopologyVertices.MeshVertexIndices(j_p)

    c0 = mesh.VertexColors.Item.GetValue(iv0)
    c1 = mesh.VertexColors.Item.GetValue(iv1)

Thank Matt

(Matt Gaydon) #2

Another question linked to this.

Whys is it that if you put a single index into mesh.TopologyVertices.MeshVertexIndices(index) it returns a single integer in an array for a primitive mesh but multiple integers for the same index in the same array for a subdivided mesh?

(Giulio Piacentino) #3

@mattgaydon Rhino stores several “simple vertices” for any topological vertex when the vertex is unwelded (so it has several normals, several texture coordinates, several UV coordinates, too).

(Matt Gaydon) #4

Thanks for the Update, in the End i just indexed the first from the list to carry on, But would be interesting to see if i picked a different number in the list if i got a different colour at that vertex. as the colour is added after the mesh was sub divided.

Also, have you tested extracting topological info and other mesh data from a mesh using Parallel’s in Python yet? Maybe its the way i coded it but i did not seem to get much improvement with trying to run multi threads on an update of the original code above using @stevebaer examples as reference.

(Giulio Piacentino) #5

Multi-threading is very case-specific. I cannot comment in general, sorry, @mattgaydon.