Announcements

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

(MEL)Why does polyEvaluate -uvShell give int array as result?

absoluteKelvin
Collaborator

(MEL)Why does polyEvaluate -uvShell give int array as result?

absoluteKelvin
Collaborator
Collaborator

I can't figure out how to make use of if. When it clearly should give a integer. Because when I use it in my code I get silly syntax warnings about Cannot cast data of type int[] to int when casting it into a variable.

https://www.artstation.com/kelvintam
0 Likes
Reply
Accepted solutions (2)
1,038 Views
6 Replies
Replies (6)

trs_andre
Collaborator
Collaborator

Well I guess you could always access $intArrayVariable[0] instead of $intArrayVariable .

Does it work in your case?

André Moreira

Game Developer / Technical Artist

LinkedIn

0 Likes

absoluteKelvin
Collaborator
Collaborator
global proc string [] KTgetUVShells()
{
   string $shellList[];
   string $objects[] = `ls -o -sl`;
   int $shellAmt[];
   int $num;
   int $shellIds[];
   int $counter = 0 ;
   for ($obj in $objects)
   {
       $shellAmt[0] = `polyEvaluate -uvShell $obj`; // get amount of uvshells in object
       $num = $shellAmt[0]; // cast the shellAmt to num to be used in for loop condition

       for($i = 0; $i < $num; $i++);
       {           
           $shellIds[size($shellIds)] = $counter; 
           $counter += 1;

       }
       
       for ($s in $shellIds)
       {
       		string $uvsInShell[] = `polyEvaluate -uis $s $obj`;  //gets the .map of the corresponding uv shell ID
		$shellList[size($shellList)] = stringArrayToString($uvsInShell, " "); //storing the uv shell into array
	   }
    }

   return $shellList;
}

KTgetUVShells;

if you run this on a mesh selected it will give

 

// Error: line 11: Cannot convert data of type int[] to type int. //

https://www.artstation.com/kelvintam
0 Likes

trs_andre
Collaborator
Collaborator
Accepted solution

IF you change to

$shellAmt = `polyEvaluate -uvShell $obj`; // get amount of uvshells in object

the error disappears. Does it help? 

André Moreira

Game Developer / Technical Artist

LinkedIn

absoluteKelvin
Collaborator
Collaborator

the error still appears for me if i run the code all together.

https://www.artstation.com/kelvintam
0 Likes

mspeer
Consultant
Consultant
Accepted solution

Hi!

 

@trs_andre  is correct, if you change

$shellAmt[0] to $shellAmt

in this specific line of your example code, then it works.

 

 

absoluteKelvin
Collaborator
Collaborator

i must have messed up somewhere. It works now thanks for the help guys.

https://www.artstation.com/kelvintam