Code.
*** Curves From Particles ***
Description:
Pymel script to generate cv curves from particle paths.









*** Cache Cloud ***
Description:
Python script that creates Maya Particle Disk Cache (PDC) files from a sequence of point cloud data, and also gives you the choice of importing a single point cloud. It could be useful with all the open source data being released from Kinect hacks or 3D scanners. You can start by playing around with Radiohead's House Of Cards data: http://code.google.com/p/radiohead/downloads/list
Watch a demo in hi-res HERE.
Also found in Creative Crash.



Downloads:
Version 0.8.4 was the first release, but is the faster one.
Version 0.9.0 is an update that contains classes and more documentation, but is slower.

Notes:
1) The point cloud data source files should be named serially (with numbers in suffix), with padding. Currently it doesn't take numbered prefixes very well. That said, you might have to rename/serialize your source files appropriately - for example, "frame001.txt" or "dynamite01.csv". Here's a good program to do so on a Mac: http://www.pathossoftware.com/Rename/Rename.html
2) For a point cloud animation, you can select a range of ordered files or a single file. If one file is selected, the remaining files in the animation sequence will be cached.
3) This version accepts CSV and TXT files containing arrays* in the form of:

integer, float, float, float
OR
float, float, float, integer
OR
float, float, float

*per line, comma-separated or whitespace-separated. Try another form of arrays at your own risk.
4) There's a bug that makes Maya crash when you play the animation past the last frame of the cache. The script automatically sets it to the appropriate timeslider range, so in the meantime just avoid changing the timeslider playback range.
5) For a single point cloud, the extra attribute selected is added automatically; for animated point clouds, you need to manually add the selected attribute after closing Cache Cloud.
6) Be aware that this script creates a new cache folder and a CacheCloud_history.txt file in your Maya workspace (in the particles directory).
7) This script has only been tested in 64-bit Maya 2011 running on OSX, but I don't see why it wouldn't work in Windows. The UI prompts are called from Maya commands.

License:
The Cache Cloud script is made available under the Creative Commons Attribution-Noncommercial-Share Alike 3.0 License.
This license lets you remix, tweak, and build upon Cache Cloud non-commercially, and although your new works must also acknowledge Daniel Vasquez (heylight.com) and be non-commercial, you don’t have to license your derivative works on the same terms.
For more information on this license, read http://creativecommons.org/licenses/by-nc/3.0/legalcode and http://creativecommons.org/licenses/by-nc/3.0/



*** Cell division in MEL ***
Description:
MEL script for mimicking binary fission using particles.


//MEL script for cell division
global proc cellDivision (string $customName, int $max, vector $initialPos, float $posOffset)
{



//create the first division if particle node [$customName] doesn't exists
if (`particleExists $customName`==0) {
nParticle -p ($initialPos.x) ($initialPos.y) ($initialPos.z) -name $customName;
setAttr "nucleus1.gravity" 0;
int $firstParticleCount=`nParticle -ct -q $customName`;
print("Cell count: " + $firstParticleCount + "n");
}

//Terminate the procedure if there are more than [$max] number of cells
else if ((`nParticle -ct -q $customName`)*2>$max) {
print("****Procedure terminated. Maximum number of cells reached.n");
}

//add particles to particle node [$customName] if it exists
else {
//this approach will make this procedure repeatable
//which that you can run it over and over until you are satisfied with the cycle count

//create an array to store current particle position vectors
vector $currentParticlePositions[];

//query current total particle count
int $particleCount=`nParticle -ct -q $customName`;
print("Cell count: " + ($particleCount*2) + "n");

//store each particle's position vector into the array
for ($i=0;$i<$particleCount;$i++) {
vector $pPosition=`nParticle -attribute position -id ($i) -q $customName`;
$currentParticlePositions[$i]= <<$pPosition.x, $pPosition.y, $pPosition.z>>;
}

vector $currentParticle;
for ($currentParticle in $currentParticlePositions) {
//get a random vector every time it loops
vector $randVector = `sphrand($posOffset)`;

//add new particles to [$customName] particle node close to current particles
vector $newerPos = `emit -object $customName -pos ($currentParticle.x + $randVector.x)
($currentParticle.y + $randVector.y)
($currentParticle.z + $randVector.z)`;
}
}

}

//run the line for one cell division cycle
//cellDivision("cells",256,<<0,0,0>>,0.15);

/*
Use this code in the expression editor
int $f = `currentTime -q`;
int $n;
if($f>$n)
{
print("Cyclen");
//print(($n += 24)+"n");
$n += 24;
cellDivision("cells",5000,<<0,0,0>>,0.15);

//Set initial state so the particles don't disappear when playback
//setNClothStartState;
//performSetNClothStartState 1;
//Track output
print ("cycle = " + $n + "n");
print ("frame = " + $f + "n");
};
*/

//string $cellDivisionProc = cellDivision("cells",512,<<0,0,0>>,0.15);
//time1.outTime = eval($cellDivisionProc);