How to assign each object a single particle (for many objects)?


#1

Hello,
I am trying to simulate many golden rhombi (GR’s) moving from one point to assemble into a number of quite a complex forms, made from hexacontahedrons (among other things) using maya (2014) dynamics. Each GR needs to end up in a specific place with a specific orientation.

Since I have already constructed the end results (sometimes from hundreds of individual polygon meshes) I have the theory (as a relative newbie with maya dynamics) that I can do the following:

  1. Assign each end position object (v simple polygon meshes) a particle.
  2. Assign all the particles a single goal end position.
  3. Create curves as motion paths from the movement of the particles.
  4. Attach the objects to the motion paths.
  5. delete the particle system.
  6. Then perhaps make the curves dynamic and play around with that.
  7. Create the animation cache and reverse the keyframes.

I have issues with 1. and 4.

  1. Can anyone tell me how I can in a procedural way attach single particles to a crowd of meshes? I am guessing I might first need to attach a locator to the pivot point of the mesh?
    I really don’t want to do this by eye-balling though.

  2. The other thing I would like to automate is making multiple motion paths by attaching objects to the open control vertex that rests at its pivot? Am I dreaming here?

If anyone can direct me on either of these issues I would be hugely grateful.

Kind regards,

Tom


#2

About 1:

Here is some MEL code that might work. I am on my phone, so i havent tried this out. It is garruanteed to be buggy. Select all the meshes, then run this:

$myList = ‘ls -sl -fl’

for ($this_mesh in $myList)
{
$PosX = ‘getAttr ($this_mesh + “.translateX”)’;
$posY = 'getAttr ($this_mesh + “.translateY”);
$posZ = 'getAttr ($this_mesh + “.translateZ”);

particle -emit -position $posX $posY $posZ;

}

Like i said, i am on my phone, so i have not tested that code in the script editor, but thats how i would solve that problem.


#3

Thanks JohnLIC,

I Don’t know enough about scripting (yet) to get your script working effectively but still it’s nice to see such straightforward melscripts to get an idea of what’s going on.
I did find another solution (at http://forums.cgsociety.org/archive/index.php/t-196278.html)
with a script that put the particles in as children of the individual meshes. That has been a good workaround but then it took alot longer to find a way to combine all particles into one object. I need to learn scripting faster :slight_smile:
Cheers, T

proc moveAndParentParticles()

{

string $daObj[]= ls -sl;

if(size($daObj)!=0)

{

for ($i in $daObj)

{

string $daLocName = “particle_”+ $i;

float $pos[3] = xform -q -ws -rp $i;

particle -p $pos[0] $pos[1] $pos[2] -n $daLocName;
parent $daLocName $i;
}
}
else { print("Nothing selected…
");
}
}
moveAndParentParticles;