Skip to content

Instantly share code, notes, and snippets.

@codedependant
Created November 12, 2012 09:17
Show Gist options
  • Save codedependant/4058311 to your computer and use it in GitHub Desktop.
Save codedependant/4058311 to your computer and use it in GitHub Desktop.
Maya Python Per Particle Expression
After Dynamics Expression
global proc setPoint(float $_index,vector $_p){
setAttr("bezierShape"+1+".controlPoints["+($_index)+"].xValue",$_p.x);
setAttr("bezierShape"+1+".controlPoints["+($_index)+"].yValue",$_p.y);
setAttr("bezierShape"+1+".controlPoints["+($_index)+"].zValue",$_p.z);
}
int $id = nParticleShape1.particleId;
vector $p = nParticleShape1.position;
int $index = 0;
if($id == 0 || $id == 1)
{
$index = $id;
setPoint($index+$id,$p);
setPoint($index+1+$id,$p);
}
Creation Expression
int $index = nParticleShape1.particleId;
$part1 = trunc(rand($index, 500));
$particleMap[$index] = $part1+","+$part1+","+$part1;
#New After Dynamics Expression
# get list of bezierCurves
$allObjects = `lsType "bezierCurve"`;
for ( $obj in $allObjects ) {
string $name = `substitute "bezierShape" $obj ""`;
print $name;
}
string $node = "pCube1|pCubeShape223";
string $suffix = `match "[0-9]+$" $node`;
// Result: "223" //
#find
string $buffer[];
tokenize($particleMap[$index],$buffer);
print $buffer;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment