Hey there, I'm having a small problem and somehow I can find a solution on the Internet. I'm trying to iterate over an array of objects and display face count with a for loop (not for in loop). I tried various syntax's but somehow I am not able to save the face count into a integer variable, what am I doing wrong? string…
Thank you for all the valuable answers! I think you are right about the return type, Bartalon. I found out that the real problem I was having is that I was using the single quote character (') instead of the accent grave character (`) when trying to type my own polyEvaluate command.
Oddly enough, despite the documentation saying that polyEvaluate -f returns an int: // Error: line 5: Cannot convert data of type int[] to type int. // Convert the type to an array and you'll be good to go: int $facecount[] = `polyEvaluate -f $pObjs[$i]`; EDIT: Had an odd thought that the command would return an array of…
polyEvaluate is a command so it goes in those single quotes as you use in: string $pObjs[] = `ls -sl`; Instead of this: int $facecount = polyEvaluate -f $pObjs[$i]; it goes like this: int $facecount = `polyEvaluate -f $pObjs[$i]`; Since i am not in front of the computer i cant give it a test if that’s the only problem.
Perhaps it has something to do with certain other polyEvaluate flags returning array values, so all return values must be an array. From what I understand of MEL, a variable can't be redefined once it's been set as something like it can in Python. That's probably why `ls -sl` always returns an array for a single object…
I'm stumped on that too. Was hoping that getting some sleep would help... but.... $facecount is a regular integer, getting a new value each time the loop runs, I don't get why maya thinks that it should be an array.