Using the Expression Editor, I am trying to get vtx[10] to follow the location of vtx[20] as the latter moves about the scene. Both vertices are part of a larger mesh that is smoothly bound to a rig. I have created (at bind pose) a Cluster that contains vtx[10], and no other vertices; its bind pose transform coordinates are (0,0,0).
Here is the code I have tried so far:
if( knee_L.anglebetween >= 90.0 )
{
setAttr "clusterHandle10Cluster.envelope" 0 ;
clusterHandle10.translateX = body.cp[20].xv - body.cp[10].xv ;
clusterHandle10.translateY = body.cp[20].yv - body.cp[10].yv ;
clusterHandle10.translateZ = body.cp[20].zv - body.cp[10].zv ;
setAttr "clusterHandle10Cluster.envelope" 1 ;
}
The envelope parameter of the Cluster is temporarily set to 0 to recalculate the the differences in coordinates between vtx[10] and vtx[20] as the smooth-bound mesh moves about in response to manipulating the rig.
Needless to say, the code doesn't get the two vertex positions to coincide. Perhaps it is the construct "polyobject.cp[n].xv" that isn't working.
Any feedback would be more than greatly appreciated! Thank you.