# Joints On A Curve

**URL:** https://forum.highend3d.com/t/joints-on-a-curve/48022
**Category:** Maya
**Tags:** rigging-character
**Created:** [July 5, 2007, 2:20pm UTC](https://forum.highend3d.com/t/joints-on-a-curve/48022 "2007-07-05T14:20:17Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![bradon](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/b/eb8c5e/32.png) [@bradon](https://forum.highend3d.com/u/bradon)
#### Post date: [July 5, 2007, 2:20pm UTC](https://forum.highend3d.com/t/joints-on-a-curve/48022/1 "2007-07-05T14:20:17Z")

</div>

anyone know a way to take a curve and layout a series of joints along the curve all spaced evenly? I guess similar to an IK spline, but in reverse where I can start with a curve and layout joints along the curve.

---

<div class="post-metadata">

### Author: ![ptb](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/p/b77776/32.png) [@ptb](https://forum.highend3d.com/u/ptb)
#### Post date: [July 8, 2007, 2:18pm UTC](https://forum.highend3d.com/t/joints-on-a-curve/48022/2 "2007-07-08T14:18:53Z")

</div>

The nicest way would be to script this (query curve position and create joint).

But here’s a non-scripting possibility:

- create a locator

- select the locator and curve, then adjust your time slider to the number of joints you want evenly spread…

- click animate → motion paths → attach to motion path

- joint tool; now create your joints while scrubbing through the timeline (use the “v” key to snap it to the locator position)

or well, another one i just thought of:

- rebuild the curve uniform with number of spans = number of joints (+1);

- now create the joint chain and snap each joint to each edit point of the curve.

---

<div class="post-metadata">

### Author: ![visualfx](https://forum.highend3d.com/user_avatar/forum.highend3d.com/visualfx/32/55919_2.png) [@visualfx](https://forum.highend3d.com/u/visualfx)
#### Post date: [July 10, 2007, 4:26pm UTC](https://forum.highend3d.com/t/joints-on-a-curve/48022/3 "2007-07-10T16:26:32Z")

</div>

Here is a basic procedure that will do what your after. You will probably want to rebuild your curve uniform first, to make sure joints are spaced evenly. The arguments $crv and $num\_jnts refer to the nurbs curve and number of joints, respectively.

CODE  
global proc rig\_joint\_crv(string $crv,int $num\_jnts){

select -cl;  
&nbsp;&nbsp;&nbsp;&nbsp;float $minu = `getAttr ($crv + ".minValue")`;  
&nbsp;&nbsp;&nbsp;&nbsp;float $maxu = `getAttr ($crv + ".maxValue")`;  
&nbsp;&nbsp;&nbsp;&nbsp;float $inc&nbsp;&nbsp;= ($maxu - $minu)/$num\_jnts;  
&nbsp;&nbsp;&nbsp;&nbsp;for($i=0;$i\<=$num\_jnts;$i++){  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float $u = $inc \* $i;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;float $jpos[] = `pointOnCurve -pr $u $crv`;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;string $joint = `joint -p $jpos[0] $jpos[1] $jpos[2]`;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}

}

---

<div class="post-metadata">

### Author: ![joojaa](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/j/5daacb/32.png) [@joojaa](https://forum.highend3d.com/u/joojaa)
#### Post date: [July 11, 2007, 1:59pm UTC](https://forum.highend3d.com/t/joints-on-a-curve/48022/4 "2007-07-11T13:59:15Z")

</div>

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) {  
&nbsp;&nbsp;select -cl;  
&nbsp;&nbsp;$info=`createNode curveInfo`;  
&nbsp;&nbsp;$shape=`listRelatives -shapes -typ "nurbsCurve" $crv`;  
&nbsp;&nbsp;connectAttr -f ($shape[0]+“.worldSpace[0]”) ($info+“.inputCurve”);  
&nbsp;&nbsp;$len=`getAttr ($info+".arcLength")`;  
&nbsp;&nbsp;$step=$len/$num\_jnts;  
&nbsp;&nbsp;string $joint[];  
&nbsp;&nbsp;for($i=1;$i\<=$num\_jnts+1;$i++){  
&nbsp;&nbsp;&nbsp;&nbsp;$joint[size($joint)] = `joint -p ($len*$i) 0 0`;  
&nbsp;&nbsp;}  
&nbsp;&nbsp;ikHandle&nbsp;&nbsp;-fj 0 -ccv 0 -curve “curve1” -sj $joint[0] -ee&nbsp;&nbsp;$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  
&nbsp;&nbsp;$div=`createNode multiplyDivide`;  
&nbsp;&nbsp;setAttr ($div+“.operation”) 2;  
&nbsp;&nbsp;setAttr ($div+“.input2X”) $len;  
&nbsp;&nbsp;connectAttr -f ($info+“.arcLength”) ($div+“.input1X”);  
&nbsp;&nbsp;for ($item in $joint){  
&nbsp;&nbsp;&nbsp;&nbsp;for ($value in {“.scaleX”,“.scaleY”,“.scaleZ”})  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;connectAttr -f ($div+“.outputX”) ($item+$value);  
&nbsp;&nbsp;}

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!

---

<div class="post-metadata">

### Author: ![boradayioglu](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/b/7ab992/32.png) [@boradayioglu](https://forum.highend3d.com/u/boradayioglu)
#### Post date: [July 11, 2007, 8:43pm UTC](https://forum.highend3d.com/t/joints-on-a-curve/48022/5 "2007-07-11T20:43:12Z")

</div>

QUOTE(bradon @ 07/05/07, 05:20 PM) [snapback]269245[/snapback]  
anyone know a way to take a curve and layout a series of joints along the curve all spaced evenly? I guess similar to an IK spline, but in reverse where I can start with a curve and layout joints along the curve.

If you still looking for a way, a friend of mine had written a mel for that;  
[http://www.ozgurfx.com/downloads/scripts/c…ointOnCurve.mel](http://www.ozgurfx.com/downloads/scripts/createJointOnCurve.mel)

bora dayioglu  
[http://www.borafx.com](http://www.borafx.com)

---

<div class="post-metadata">

### Author: ![laz84](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/l/7bcc69/32.png) [@laz84](https://forum.highend3d.com/u/laz84)
#### Post date: [July 30, 2007, 12:22pm UTC](https://forum.highend3d.com/t/joints-on-a-curve/48022/6 "2007-07-30T12:22:35Z")

</div>

As per usual theres many different ways to do things in Maya which is why we love it so much right? To illustrate this fact heres another way. change the first variable to how many joints you want along the curve, select the curve and run this.

CODE  
float $numJoints = 50;  
string $selCurve[] = `ls -sl`;  
string $curveShape[] = `listRelatives -s`;  
float $jointSpace = 1 / ($numJoints - 1);

$tmpPOCI = `createNode pointOnCurveInfo`;  
setAttr ($tmpPOCI + “.turnOnPercentage”) 1;  
connectAttr ($curveShape[0] + “.worldSpace”) ($tmpPOCI + “.inputCurve”);

int $a = 0;  
float $parameter = 0;  
float $jointPos[];  
while ($a \< $numJoints) {  
&nbsp;&nbsp;&nbsp;&nbsp;$parameter = $parameter + $jointSpace;  
&nbsp;&nbsp;&nbsp;&nbsp;$jointPos = `getAttr ($tmpPOCI + ".position")`;  
&nbsp;&nbsp;&nbsp;&nbsp;joint -p $jointPos[0] $jointPos[1] $jointPos[2];  
&nbsp;&nbsp;&nbsp;&nbsp;setAttr ($tmpPOCI + “.parameter”) $parameter;  
&nbsp;&nbsp;&nbsp;&nbsp;$a++;  
}

delete $tmpPOCI;

This one yields similar results to visualfx post, so if the curve isn’t uniform then the joints will retain the proportions of the cv layout of your curve.
