# Getattr And For Loops

**URL:** https://forum.highend3d.com/t/getattr-and-for-loops/3597
**Category:** Maya
**Tags:** mel
**Created:** [September 28, 2005, 10:13pm UTC](https://forum.highend3d.com/t/getattr-and-for-loops/3597 "2005-09-28T22:13:07Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![shadowmonk](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/s/a9a28c/32.png) [@shadowmonk](https://forum.highend3d.com/u/shadowmonk)
#### Post date: [September 28, 2005, 10:13pm UTC](https://forum.highend3d.com/t/getattr-and-for-loops/3597/1 "2005-09-28T22:13:07Z")

</div>

Ok, here is my problem. I'm trying to go through a list of selected objects to change an attribute. Here is the code I am trying to get to work:

CODE  
&nbsp;&nbsp;&nbsp;&nbsp;string $selected[] = `ls -selection`;  
&nbsp;&nbsp;&nbsp;&nbsp;string $object, $type;  
&nbsp;&nbsp;&nbsp;&nbsp;int $size = size($selected);

&nbsp;int $i;  
&nbsp;&nbsp;&nbsp;&nbsp;for($i = 0; $i \< $size; $i++)  
&nbsp;&nbsp;&nbsp;&nbsp;{  
 &nbsp;$object = $selected[$i];  
 &nbsp;$type = `getAttr ._lptType $object`;  
&nbsp;&nbsp;&nbsp;&nbsp;}

It tells me that it cannot evaluate more than one attribute, but to me it looks like that's what I'm doing, only evaluating one attribute! I have tried some other things, but can't seem to figure out why Maya is complaining! Thanks for any help

---

<div class="post-metadata">

### Author: ![joojaa](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/j/5daacb/32.png) [@joojaa](https://forum.highend3d.com/u/joojaa)
#### Post date: [September 29, 2005, 6:13am UTC](https://forum.highend3d.com/t/getattr-and-for-loops/3597/2 "2005-09-29T06:13:15Z")

</div>

change $type = `getAttr .\_lptType $object`;

to $type = `getAttr "$object+.\_lptType"`;

---

<div class="post-metadata">

### Author: ![naughty](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/n/35a633/32.png) [@naughty](https://forum.highend3d.com/u/naughty)
#### Post date: [September 29, 2005, 9:06am UTC](https://forum.highend3d.com/t/getattr-and-for-loops/3597/3 "2005-09-29T09:06:57Z")

</div>

QUOTE(shadowmonk @ 09/28/05, 02:13 PM)  
Ok, here is my problem.&nbsp; I'm trying to go through a list of selected objects to change an attribute.&nbsp; Here is the code I am trying to get to work:  
CODE  
&nbsp;&nbsp;&nbsp;&nbsp;string $selected[] = `ls -selection`;  
&nbsp;&nbsp;&nbsp;&nbsp;string $object, $type;  
&nbsp;&nbsp;&nbsp;&nbsp;int $size = size($selected);

---

<div class="post-metadata">

### Author: ![joojaa](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/j/5daacb/32.png) [@joojaa](https://forum.highend3d.com/u/joojaa)
#### Post date: [September 29, 2005, 2:09pm UTC](https://forum.highend3d.com/t/getattr-and-for-loops/3597/4 "2005-09-29T14:09:33Z")

</div>

yes your right must be the lack of sleep ![](http://www.highend3d.com/boards/style_emoticons/<#EMO_DIR#>/smile.gif) now ythat i finaly got soem theres a EVEN shorter way of doing this namelyexecuteForEachObject ist a bit heavy on your tprocessing so its better not to use it unless yoru actualy doing something thats very ad hoc. And does not work too well either. but it has ists veryy limitted uses

---

<div class="post-metadata">

### Author: ![shadowmonk](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/s/a9a28c/32.png) [@shadowmonk](https://forum.highend3d.com/u/shadowmonk)
#### Post date: [September 29, 2005, 3:38pm UTC](https://forum.highend3d.com/t/getattr-and-for-loops/3597/5 "2005-09-29T15:38:36Z")

</div>

Thanks a lot! Got it working ![](http://www.highend3d.com/boards/style_emoticons/<#EMO_DIR#>/smile.gif)
