How to loop through UV shell face selection in Mel?

How to loop through UV shell face selection in Mel?

malcolm_341
Collaborator Collaborator
421 Views
1 Reply
Message 1 of 2

How to loop through UV shell face selection in Mel?

malcolm_341
Collaborator
Collaborator

I'm trying to store my UV shells into an array and loop through them, the problem is UVs change their index if you apply UV mapping after storing the shells in an array which I need to do in my script. So I need to store each UV shell in a face array and then loop through each shell in face mode not each face individually. I can store the face collections in arrays using the eval command, but I can't figure out how to get them out of that loop, I can't figure out how to store them in global variables and then select those global variables in the next loop. Here's what I've got anyone know how to finish it?

To run the script you need to select all the faces of some individual shells in the UV editor.

ConvertSelectionToUVShell;
string $findShells[] = texGetShells();
int $numbShells = `size $findShells`;
int $shellIndex = 0;
string $shellToken[] = {};
int $fCounter = 0;

for ($item = 0; $item < $numbShells; ++$item)
{
	tokenize($findShells[$shellIndex], $shellToken);
	select $shellToken;
	
	ConvertSelectionToFaces;
        eval ("global string $testFaces" + $sCounter + "[];");
	eval ("$testFaces" + $sCounter + " = `ls -sl -fl`;");

	$fCounter = $fCounter + 1;
	$shellIndex = $shellIndex + 1;
}

//This next part of the code doesn't work and I'm not sure why it won't select the shells I defined above?
$fCounter = 0;
for ($item = 0; $item < $numbShells; ++$item)
{
        eval ("global string $testFaces" + $sCounter + "[];");
	eval ("select $testFaces" + $sCounter + ";");

        //Do code here
        print "Found shell\n";

	$fCounter = $fCounter + 1;
}	

 

 

Accepted solutions (1)
422 Views
1 Reply
Reply (1)
Message 2 of 2

malcolm_341
Collaborator
Collaborator
Accepted solution

I had a spelling mistake in my code and it works as intended now. Here is the working code.

ConvertSelectionToUVShell;
string $findShells[] = texGetShells();
int $numbShells = `size $findShells`;
int $shellIndex = 0;
string $shellToken[] = {};
int $fCounter = 0;

	
for ($item = 0; $item < $numbShells; ++$item)
{
	tokenize($findShells[$shellIndex], $shellToken);
	select $shellToken;
		
	//Store shell faces so unitize doesn't mess up selection
	ConvertSelectionToFaces;
        eval ("global string $testFaces" + $fCounter + "[];");
	eval ("$testFaces" + $fCounter + " = `ls -sl -fl`;");

	$fCounter = $fCounter + 1;
	$shellIndex = $shellIndex + 1;
}
	
$fCounter = 0;
for ($item = 0; $item < $numbShells; ++$item)
{
        eval ("global string $testFaces" + $fCounter + "[];");
	eval ("select $testFaces" + $fCounter + ";");

        //Do code here
        print "Found shell\n";

	$fCounter = $fCounter + 1;
}