Hi there, I was about to script something like this, but I get stuck when I need to plug each locator to each cv of the curve… as you can see I did put [6] but of course is wrong… there is something missing or wrong in that specific for loop.
Here is the code:
//creating curve guide
string $createCurveGuide = curve -d 1 -p 0 0 0 -p 0 30 0 -k 0 -k 1 -n ("Spline" + "_crv");
string $curveGuide[] = rebuildCurve -ch 1 -rpo 1 -rt 0 -end 1 -kr 0 -kcp 0 -kep 1 -kt 0 -s 5 -d 3 -tol 0.01 $createCurveGuide;
string $curveGuideShape[] = listRelatives -s $curveGuide[0] ;
//STORE SOME VARIABLES–
string $selCurve[] = $curveGuide ;
int $noSelCurve = size($selCurve);
//THIS IS THE FOR LOOP FOR CREATING JOINT CHAIN ON SELECTED CURVES—
for ($i=0;$i<($noSelCurve);$i++)
{
select -r ($selCurve[$i] + “.cv[li]”);
[/li] string $cvPos[] = ls -sl -flatten;
//THIS LOOP CREATES A Locator FOR EACH CV IN THE CURVE---
string $oldLoc = "";
for ($cv in $cvPos)
{
string $createLocPos[] = ` spaceLocator `;
string $createSplineLocName[] = ` js_hashRename ("_Spline" + "_POS_##") `;
string $decompMatrix = ` createNode decomposeMatrix -n ("_decMat") `;
float $xyz[] = ` xform -a -ws -q -t $cv `;
xform -a -ws -t $xyz[0] $xyz[1] $xyz[2] $createSplineLocName[0];
// connecting each loc worldspace to each cv in curve, in order to follow
string $locMatrix[] = $createSplineLocName ;
int $noLocMatrix = `size($locMatrix)`;
for ($i=0;$i<($noLocMatrix);$i++)
{
connectAttr -f ($createSplineLocName[$i] + ".worldMatrix[0]") ($decompMatrix + ".inputMatrix") ;
connectAttr -f ($decompMatrix + ".outputTranslate") ($curveGuideShape[0] + ".controlPoints[6]");
}
if ($oldLoc != "")
{
parent $createSplineLocName[0] $oldLoc;
}
$oldLoc = $createSplineLocName[0];
}
}