Hi, I know, that most of you would solve this problem otherwise. My coding-skills are not very good, but anyway:
[codebox]string $SelObjects[] = ls -sl; // save Names of current Selection to string-Array int $NumberOfSelObj = size $SelObjects; // save Number of selected Objects to int-Variable
Why would anybody bother with doing that? I mean its shorter to write the proper code and its 2 times faster. See gmasks answer.
QUOTE(andy_davis @ 07/01/09, 03:51 PM) [snapback]310567[/snapback] I found that I had to use eval for a polyUnite command. I was trying to send it a list of objects in a string array...
CODE polyUnite -ch 1 ($Objects)
but that didn't work
Are you REALLY sure? I mean test: CODE { $ls=ls -sl; polyUnite -ch 1 $ls; }
Works fine, for me, no eval. So if yoru code does indeed not work, then please report the maya version you get this problem with, as sure as hell teh 8.5 im running right now works fine. (will test 2009 when i get to a computer that has it). IF THIS DOES NOT INDEED WORK, then mayas on verge of self collapsing and this is indeed a very serious bug. That need to be reported to autodesk ASAP.
Odds are theres a declaration problem in your code instead. QUOTE(andy_davis @ 07/01/09, 03:51 PM) [snapback]310567[/snapback] Sometimes, I find it hard to avoid eval!
Like i said theres only 3 things you need to use eval for one of them looks a bitlike yours but its using a huge setAttr statement, for loong float array. because looping setattr is veryy inneficent. In reality when you see people using eval its often more of sign that they dont know how to THINK about code than anything else. The second is a jump point, they actually DOCUMENT THIS. And the 3 is if you need to use source at code time, see the docs on eval and source. So 90% of time when i see eval i see code thats stupid anyways.
Fine in guis tough since that's a jump point usage. So send me the code where you THINK you need eval an i will re-engineer it to not use eval. (jump points are sane because they are function pointers anyway.)
So mel rules of thumb are
If you use eval the likelihood is your doing things wrong, or misunderstood the problem.
If your using script jobs then the likelihood is slightly smaller but close to same. Especially if you find you need 30 script jobs
[quote name='Joojaa' date='07/01/09, 09:52 PM' post='310573'] [img]style_emoticons/<#EMO_DIR#>/laugh.gif[/img] Why would anybody bother with doing that? I mean its shorter to write the proper code and its 2 times faster. See gmasks answer.
Of course, I know , I just answer questions Eval - Problem