I’ve recently started learning python and began with creating some small tools for maya.
The tool I’m currently working on selects vertices based on the vertex color & tolerance value set by the user.
So far the tool I’ve created works fine but I’m running into a performance issue.
When I run the tool on a plane with 8000 triangles, it takes less than 1 second to cycle through all the vertices and deselect the ones that don’t have the desired vertex color.
After moving the mesh around in maya the same script suddenly takes over 13 seconds to complete.
The issue seems to originate from the following part of my script:
# List with per channel color value of every vertex that's selected colors = cmds.polyColorPerVertex(query=True, r=True, g=True, b=True, nun=True) # Array that stores float3 vertex colors vArray =  # For loop that collects rgb values for each vertex & adds them to vArray for i in range(len(verts)): cArray =  for c in range(3): cIndex = i * 3 + c if colors[cIndex] > 1.0: colors[cIndex] = 1.0 cArray.append(colors[cIndex]) vArray.append(cArray) # Check if the vertex color is within the range that is declared by the user if not toleranceCheck(vArray[i], vColor, tolerance): cmds.select(verts[i], d=True)
I’ve tried to debug where the decrease in performance was coming from (using cmds.timer) but the only thing I could find is that the deselect command itself just seems to take longer.
Any help would be really appreciated.