I've got the following problem: I am simulating an nCloth mesh in Maya 2011. So far, I found that the particle data of the nClothShape node is accessible, and I can even attach dynamic expressions to it like with a particleShape node (i.e. I get expressions to run before and after the dynamic calculations, as well as at particle creation).
What I need to do in one such expression, is find what vertex (in the mesh that the nCloth simulation is deforming for me) corresponds to a given nCloth particle. In this particular case, the nCloth is tearing by means of a tear constraint. When the tear constraint is created, the nClothShape immediately creates extra particles on the vertices that are assigned to this constraint, in order to simulate the two sides of the tear. But the mesh only has the original amount of vertices, until the tear rips. Only at that point, will the mesh have an additional vertex for each ripped vertex. But how can I know which nCloth particle is connected to which vertex using MEL?
At first I (sheepishly) assumed that the vertex IDs on the output mesh would always correspond to the nCloth particle IDs, but since the nCloth particles are created right away, while the mesh vertices are obviously not, this is not true.
I have found a (rather clumsy) way to query which vertex is closest to a given position in space, using the polySelectConstraint command, but there has to be a better and more reliable way to figure out the relation between nCloth's particles and the vertices of the outputMesh node.
Any help would be greatly appreciated.