The problem is not the positioning. Problem is to get the euler rotaion from the Vector of the selected face.
Good ol polyInfo -faceNormals delivers the face normal in its weirdy manner. So here is a helper for the start:
CODE
global proc float[] getPolyFaceNormals(string $faces[])
{
// expand face input
$faces = filterExpand -ex 1 -sm 34 $faces
;
// if nothing given take selection
if (!size($faces)) $faces = filterExpand -ex 1 -sm 34
;
float $return[];
int $count = 0;
for ($face in $faces)
{
string $polyInfo[] = polyInfo -faceNormals $face
;
string $buffer[];
tokenize $polyInfo[0] $buffer;
$return[$count++] = $buffer[2];
$return[$count++] = $buffer[3];
$return[$count++] = $buffer[4];
}
return $return;
}
Put in an array of faces and get an array of float normals.
Oh boy you are lucky that I'm interested in this. I wouldn't do a keystroke otherwise ;]
OK. Now how to get the euler rotation from that vector?
I think we have to project the vector on each plane and get the angle via angle command.
CODE
float $faceNormal[] = getPolyFaceNormals($selFace);
float $eulerRot[];
$eulerRot[0] = rad_to_deg(angle <<0, $faceNormal[1], $faceNormal[2]>> <<0,1,0>>
);
$eulerRot[1] = rad_to_deg(angle <<$faceNormal[0], 0, $faceNormal[2]>> <<1,0,0>>
);
$eulerRot[2] = rad_to_deg(angle <<$faceNormal[0], $faceNormal[1], 0>> <<0,1,0>>
);
But thats still not it.. I had this problem already. We have to flip some axes here if they are negative or something...