### Index > 3D Forums > Maya Boards > MEL

Jan 05, 2012
Post id: 309396

Hi everyone

I have a project where I would like to get the "snapping" effect of using the step size in the rotation tool directly on a kinematic chain.  Essentially, I want it to snap to 5 degree increments.  I have been working on the expression, but I can't quite get it to work. My thought at the moment is to make a second IK chain that reads from the first one and interpolates the value to the second.....

If anyone has tried this before, or if I'm missing something simple, I would appreciate the input

Nick

Jan 06, 2012
Post id: 309413

Alright, I don't know where my brain was on this.... using a "proxy" is really simple. Assuming 2 simple boxes the expression is pretty easy, but I am curious if anyone knows how to do this witout the second object.

int \$stepVal = 10;

float \$inputVal = pCube1.rotateY;

float \$division = \$inputVal/\$stepVal;

int \$outVal;

if(ceil(\$division)-\$division<=0.5)

{

\$outVal=ceil(\$division)*\$stepVal;

}

else

{

\$outVal=floor(\$division)*\$stepVal;

}

pCube2.rotateY=\$outVal;

Jan 06, 2012
Post id: 309415

well it certainly is easier (by the way you dont need the if clause you can just sum your rounding point to the division and use just ceil or floor depending in wether you used subtraction or addition)

>> how to do this witout the second object.

Tools work differently form connections, when i first saw this post i tought not really worth it. But hwoever you can do this with a proxy that is not visible then move the shape under the proxy via a shape transform now you have a proxy tahts invisible connected to the shape thats driven by the proxys child. Offcourse i suspect this does not work snce you cant animate the damn thing.

Ok you can do this also with expressions AND not using a connection again a kludge, and again you cant animate the damn thing.

You can use a proxy attribute Butthen you cant us e normal tools to animate.

then you can redirect the selection. That would actually work but its a bit painfull to keep in sync. Its actually easir to trigger rotation snap when you select the object.

A constraint MIGHT work tiough would need to test, but i bet it realy does not.

You could worite your own dag node tough.

Or you could wirte your own tool and ovveride the tool of your object with that

Jan 11, 2012
Post id: 309436

Thanks Joojaa

After working with it a bit I actually liked having both skeletons to see the exact target as well as the rounded one.  I ended up just writing it as a simple python DAG node and added a value that would let me set the "rounding point" for finer control.