Moving Verts based on UV Position


#1

Hi,

I am still a beginner at scripting. I am trying to store the position of the UVs of a specific mesh and then apply that position to the relevant verteces. So that the verteces are layed out just like the UVs. The MEL script I have come up with does not work and I was hoping someone could help me correct the script in MEL.

string $objSel[] = `ls -sl`;
 pickWalk -d down;
 string $shapeSel[] = `ls -sl`;
 ConvertSelectionToVertices;
 string $vertSel[] = `ls -sl -fl`;
 ConvertSelectionToUVs;
 string $uvSel[] = `ls -sl -fl`;
 
 for($eachUV in $uvSel)
 {
 	float $uvPos[2] = `polyEditUV -q $eachUV`;
 	ConvertSelectionToVertices;
 	xform -t $uvPos[0] $uvPos[1] 0; 
 }
 

#2

So I have been playing around a little more, trying to use the setAttr command to move the CVs. When I execute the following script, I get the

Error: Line 19.31: Illegal operation “+” on data of type string[].

Not sure what the problem is, here is the script:

string $objSel[] = `ls -sl`;
  pickWalk -d down;
  string $shapeSel[] = `ls -sl`;
  print $shapeSel;
  ConvertSelectionToVertices;
  string $vertSel[] = `ls -sl -fl`;
  ConvertSelectionToUVs;
  string $uvSel[] = `ls -sl -fl`;
  
  for($eachUV in $uvSel)
  {
  	float $uvPos[2] = `polyEditUV -q $eachUV`;
  	print $uvPos[0];
  	string $tokens[];
  	tokenize $eachUV "[]" $tokens;
  	print $tokens[1];
  	ConvertSelectionToVertices;
  	setAttr ("\"" + $shapeSel + ".pnts[" + $tokens[1] + "].pntx" + "\"") $uvPos[0];	
  }

#3

$shapeSel is an array but you’re not putting in an array position.
i.e $shapeSel[0]