Heres a alternative and slightly different way (above assumes curve is actually uniform in parametrisatrion, it don't need to be if you dont want it to with this code):
CODE
proc allmostAbove(string $crv,int $num_jnts) {
select -cl;
$info=createNode curveInfo
;
$shape=listRelatives -shapes -typ "nurbsCurve" $crv
;
connectAttr -f ($shape[0]+".worldSpace[0]") ($info+".inputCurve");
$len=getAttr ($info+".arcLength")
;
$step=$len/$num_jnts;
string $joint[];
for($i=1;$i<=$num_jnts+1;$i++){
$joint[size($joint)] = joint -p ($len*$i) 0 0
;
}
ikHandle -fj 0 -ccv 0 -curve "curve1" -sj $joint[0] -ee $joint[size($joint)-1] -solver ikSplineSolver;
}
its almost as long as above but it does generate the ik efflector too. the curve info node can be deleted once done, but i left it there in the example just inn case you wanted a strech controll. then just add following befre last }
CODE
$div=createNode multiplyDivide
;
setAttr ($div+".operation") 2;
setAttr ($div+".input2X") $len;
connectAttr -f ($info+".arcLength") ($div+".input1X");
for ($item in $joint){
for ($value in {".scaleX",".scaleY",".scaleZ"})
connectAttr -f ($div+".outputX") ($item+$value);
}
this way you can use the lock len of curve to disable stretching and unlock to stretch
PS: but the above code posted byvisualfx is quite usefully for other things So its as good aswell. it deos have a dvantage to my code if theres just a few segments tough!