Thread: Mel scripting
View Single Post
# 3 08-03-2011 , 09:43 AM
Registered User
Join Date: Mar 2011
Posts: 4
Hi Laurie,

Thank you for your quick reply..
I hope that i am over complicating the situation here, but all i really need it to select all the world x facing faces of a poly object, front and back faces.
I am creating over 500 polygon houses and need to uv project all the walls, this is very time consuming to manually select all the x faces and project, invert my selection and project on the z.

I have been looking for days for a simple solution..

Could you maybe help with a simpler solution.
I have a generic poly cube names pCube1.
Here is where i am:

//Select all the faces of an object
select -r pCube1.f["*"];

//now get the number of faces in the selection
$faceList = `filterExpand -sm 34`;

//check that i have all the faces
print $faceList;

print ("Num of faces is: " + size($faceList) + "\n");

//Now get the per face normal direction of the selection
polyInfo -faceNormals;

I am a little stuck here, I need to convert the "polyInfo -faceNormals" into a usable variable array.
I found this but not sure how it works or how to use it:


proc vector translatePolyInfoNormal( string $pin )
{

vector $normal;
float $x;
float $y;
float $z;

string $tokens[];
int $numTokens = `tokenize $pin " " $tokens`;

// Make sure we're looking at polyInfo data:
if ( ( $numTokens > 3 ) && ( $tokens[0] == "FACE_NORMAL" ) )
{
// Maya performs data-type conversion here.
$x = ($tokens[$numTokens-3]);
$y = ($tokens[$numTokens-2]);
$z = ($tokens[$numTokens-1]);

$normal = << $x, $y, $z >>;

// Normalize it.
$normal = `unit $normal`;
}

// Return it.
return $normal;
print $normal;
}


My thinking in words is as follows:
Select the object, put the selected face numbers into an array, query the face normal vector direction and store them in an array. do a for loop using the face number size as the amount of loops to check if the x value of the face normal vector direction is within certain paramaters, if so then select that face. do the loop untill all the desired faces are selected.

I know it seems simple, but I really am battling with it.
Thank you for your time