Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Apply Cluster deformer to individual nParticles using a for loop

Apply Cluster deformer to individual nParticles using a for loop

Anonymous
Not applicable
610 Views
2 Replies
Message 1 of 3

Apply Cluster deformer to individual nParticles using a for loop

Anonymous
Not applicable

Hi, 

 

I'm trying to write a macro that selects individual nParticles then applies a cluster deformer to each particle in turn.  The steps I'd like to follow would involve the following:

1) Use the particle tool to paint a random number of nparticles in the workspace

2) Run the following code to pick out each nparticle in turn and add a cluster deformer to it:

 

int $partCount = getAttr("nParticleShape1Deformed.count");
for ($i=0; $i<$partCount;$i++)
{
select -r nParticle1.pt"["+$i+"]";
newCluster " -envelope 1";
};

 

When I run the above code I get an error relating to the syntax I've used in applying the "i" counter to the selection of each nparticle in the loop.  What am i doing wrong??

 

Any and all suggestions would be very welcome.

D

0 Likes
Accepted solutions (1)
611 Views
2 Replies
Replies (2)
Message 2 of 3

mspeer
Consultant
Consultant
Accepted solution

Hi!

Try this:

select -r ("nParticle1.pt[" + $i + "]");
0 Likes
Message 3 of 3

Anonymous
Not applicable

You, my friend are a star.  Thanks a lot!

D

0 Likes