# How To Operate On A Current Selection?

**URL:** https://forum.highend3d.com/t/how-to-operate-on-a-current-selection/1284
**Category:** Maya
**Tags:** mel
**Created:** [October 23, 2008, 4:51pm UTC](https://forum.highend3d.com/t/how-to-operate-on-a-current-selection/1284 "2008-10-23T16:51:06Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![schoenefeldt-andreas](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/s/2acd7d/32.png) [@schoenefeldt-andreas](https://forum.highend3d.com/u/schoenefeldt-andreas)
#### Post date: [October 23, 2008, 4:51pm UTC](https://forum.highend3d.com/t/how-to-operate-on-a-current-selection/1284/1 "2008-10-23T16:51:06Z")

</div>

Hello,

I would like to read the name and position of objects in the current selection. I have created the objects in a namespace LOC , so that I can select them easily with:

CODE  
select "LOC:\*";

And then the trouble starts. I would like to read the name and position of every selected object and write it in a file, but i have no Idea, how to work with a selection of more then one object.

I tried to write the selection in an arrayCODE  
$bla[] = `sets -q`  
, but it is still empty afterwords.

Maybe it is a very simple problem, but I don't see the solution in the docs.

thank you for your help ![]()

Andreas

---

<div class="post-metadata">

### Author: ![ewerybody](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/e/bcef8e/32.png) [@ewerybody](https://forum.highend3d.com/u/ewerybody)
#### Post date: [October 23, 2008, 6:49pm UTC](https://forum.highend3d.com/t/how-to-operate-on-a-current-selection/1284/2 "2008-10-23T18:49:15Z")

</div>

easy dude! :]

if you'd like all objects with the name LOC:\* you even don't need to select them:  
you can pack them into an array with:

CODE  
{  
&nbsp;&nbsp;&nbsp;&nbsp;string $LOCArray[] = `ls "LOC:*"`;  
&nbsp;&nbsp;&nbsp;&nbsp;print $LOCArray;  
}

browsing them is easy with the for-in loop:

CODE  
{  
&nbsp;&nbsp;&nbsp;&nbsp;string $LOCArray[] = `ls "LOC:*"`;  
&nbsp;&nbsp;&nbsp;&nbsp;for ($item in $LOCArray)  
&nbsp;&nbsp;&nbsp;&nbsp;{  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print ("$item: " + $item + "\n");  
&nbsp;&nbsp;&nbsp;&nbsp;}  
}

But if you want to put them all to a file you could easily sort the array to a string and write that. Hava look at the fprint-example in the docs. The string you could do with:

CODE  
{  
&nbsp;&nbsp;&nbsp;&nbsp;string $LOCArray[] = `ls -type transform "LOC:*"`;

&nbsp;&nbsp;&nbsp;&nbsp;string $yourString = stringArrayToString($LOCArray,"\n");  
&nbsp;&nbsp;&nbsp;&nbsp;print ("$yourString:\n" + $yourString + "\n");  
}

I even put the -type transform to the ls command, you might get rid of the shapes.. I dunno...  
eRiC

---

<div class="post-metadata">

### Author: ![schoenefeldt-andreas](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/s/2acd7d/32.png) [@schoenefeldt-andreas](https://forum.highend3d.com/u/schoenefeldt-andreas)
#### Post date: [October 24, 2008, 1:10pm UTC](https://forum.highend3d.com/t/how-to-operate-on-a-current-selection/1284/3 "2008-10-24T13:10:42Z")

</div>

Yes!

thank you a lot. That was exactly the point.

good luck
