Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® Maya® / MEL / How to save particleIDs in a variable after selecting a bunch of particles in the viewport?
  RSS 2.0 ATOM  

How to save particleIDs in a variable after selecting a bunch of particles in the viewport?
Rate this thread
 
43351
 
Permlink of this thread  
avatar
  • Total Posts: 10
  • Joined: 10 October 2006 03:40 PM

Hi,
I’ve been facing problem with saving the particle IDs of selected particles in a variable.
This is what I am doing:

Selected few random particles( particleShape1) in the viewport in component mode and ran the code:

string $sel[] = `ls -sl`;
for($each in $sel)
{
print ($each + “\n")
}

Result:

particle1.pt[4]
particle1.pt[11]
particle1.pt[27:30]
particle1.pt[32]
particle1.pt[43]

Now my problem is, how can I store only the numbers in a variable? from the above example, I only want the numbers 4, 11, 27, 28, 29 and so on in a variable, not the whole string particle1.pt[4] or particle1.pt[11]
One problem could be that here it stores the output as a string. Did some tests on getParticleAttr, but no progress.
I am not sure how to go about it, or maybe my whole approach is wrong.

NEED HELP!!!!!

Thanks



Replies: 0
avatar
  • THNKR
  • Posted: 18 May 2010 05:54 AM

select -cl  ;
select -r particle1.pt[10] ;
select -tgl particle1.pt[52] ;
select -tgl particle1.pt[57] ;
select -tgl particle1.pt[80] ;
select -tgl particle1.pt[113] ;
select -tgl particle1.pt[95] ;
getParticleAttr -at id -array true `ls -sl`;
// Result: 10 52 57 80 95 113 //


Replies: 1
/img/forum/dark/default_avatar.png

WOW!! Just one line command :)
I’ve just recently started studying MEL. Thanks so much for your help.
Cheers!

Author: ..::sMAYAp::..

Replied: 18 May 2010 08:49 AM