global proc particleCurvesRI() {
// Get the name of the shape node
string $shapeNode = `rman ctxGetObject`;
string $parents[] = `listRelatives -parent $shapeNode`;
string $tformNode = $parents[0];
string $attr;
$attr = `rmanGetAttrName "pc_width"`;
$attr = `rmanGetFullSharedGeometricAttrName $shapeNode $attr`;
float $pc_width = `getAttr $attr`;
$attr = `rmanGetAttrName "pc_round"`;
$attr = `rmanGetFullSharedGeometricAttrName $shapeNode $attr`;
int $pc_round = `getAttr $attr`;
$attr = `rmanGetAttrName "pc_attrname"`;
$attr = `rmanGetFullSharedGeometricAttrName $shapeNode $attr`;
string $pc_attrname = `getAttr $attr`;
int $globalStart = getAttr("defaultRenderGlobals.startFrame");
int $globalEnd = getAttr("defaultRenderGlobals.endFrame");
// The heavy lifting is done by a python script
python("from particle_curves import ParticleCurves");
// Frame 1 always creates a new instance of MoCapRMan
string $instanceName = $tformNode;
string $instanceStr = $instanceName + " = ParticleCurves('" + $tformNode + "'," + $pc_round + ",'" + $pc_attrname + "')";
int $currentTime = `currentTime -q`;
// Ensure we have one instance ParticleCurves rather than for
// each frame of animation.
if($currentTime == 1)
python($instanceStr);
string $tryStr;
$tryStr = "try:\n";
$tryStr += " if " + $instanceName + " == None:\n" ;
$tryStr += " " + $instanceStr + "\n";
$tryStr += "except:\n";
$tryStr += " print('Exception: cannot create instance of ParticleCurves')\n";
python($tryStr);
$cmd = $instanceName + ".bakeCurves(" + $pc_width + ")";
python($cmd);
// If a proxy object is used make it "inactive"
RiAttribute "visibility" "int camera" 0;
RiAttribute "visibility" "int indirect" 0;
RiAttribute "visibility" "int transmission" 0;
}