# ParticlePosition to text file

**URL:** https://forum.highend3d.com/t/particleposition-to-text-file/603
**Category:** Maya
**Tags:** mel
**Created:** [December 19, 2010, 7:33am UTC](https://forum.highend3d.com/t/particleposition-to-text-file/603 "2010-12-19T07:33:31Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ruchit](https://forum.highend3d.com/user_avatar/forum.highend3d.com/ruchit/32/127_2.png) [@ruchit](https://forum.highend3d.com/u/ruchit)
#### Post date: [December 19, 2010, 7:33am UTC](https://forum.highend3d.com/t/particleposition-to-text-file/603/1 "2010-12-19T07:33:32Z")

</div>

Friends i want output like this in text file  
Output:  
ID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PositionX&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PositionY&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PositionZ  
1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 21&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 12&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 16  
2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 16&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 41&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 23   
3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 11&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 8&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 19

i made this tiny window without any command.So,now tell me how can i do this ??  
 ![](http://i410.photobucket.com/albums/pp186/ruchitinfushion/ParticleExport.png?t=1292743767)

---

<div class="post-metadata">

### Author: ![nowayfra](https://forum.highend3d.com/user_avatar/forum.highend3d.com/nowayfra/32/76_2.png) [@nowayfra](https://forum.highend3d.com/u/nowayfra)
#### Post date: [December 19, 2010, 9:08am UTC](https://forum.highend3d.com/t/particleposition-to-text-file/603/2 "2010-12-19T09:08:48Z")

</div>

You simply would write a little procedure what does the print job and map it to your "export" button. The print function would check the particle count of your object and iterate through all individual particles and read out the positions and print it to your file. Wouldnt be much more than this few lines

$fileId = `fopen "c:/exampleFile.txt" "w"`;  
fprint $fileId("ID PositionX PositionY PositionZ\n");  
for($i=0;$i\<`getAttr particleObject.count`;$i++)  
{  
&nbsp;&nbsp; &nbsp;float $p[] = `xform -q -ws -t ("particleObject.pt[" + $i + "]")`;   
&nbsp;&nbsp; &nbsp;fprint $fileId ($i + " " + $p[0] + " " + $p[1] + " " + $p[2] + "\n");  
};  
fclose $fileId;

You not neccessarily need to make a procedure out of it but it makes it a lot easier when assigning this script to your button.

---

<div class="post-metadata">

### Author: ![ruchit](https://forum.highend3d.com/user_avatar/forum.highend3d.com/ruchit/32/127_2.png) [@ruchit](https://forum.highend3d.com/u/ruchit)
#### Post date: [December 19, 2010, 12:28pm UTC](https://forum.highend3d.com/t/particleposition-to-text-file/603/3 "2010-12-19T12:28:13Z")

</div>

Oh thank you very much
