//---------------| Have to evaluate up to 100 to ensure enough calculation have been made
for ($a = 0; $a<100; $a++){
float $arcLeng_01 = `getAttr crv_length_01.arcLength`;
float $CT_top = `getAttr clus_track_top.translateY `;
//--------------| Value the translateY increases when length is not met
float $upVal = 0.1;
if ($arcLeng_01<27.087){
setAttr "clus_track_top.translateY" ($CT_top+$upVal);
}
if ($arcLeng_01>27.087){
setAttr "clus_track_top.translateY" ($CT_top-$upVal);
}
}
What I need help with is this expression wont run while I’m manipulating the rig but only when I change keyframes. Possible ideas are to switch to using hypershade nodes rather than expressions or just finding a new way.
Any thoughts would be greatly appreciated!
Thanks!
EDIT:
I have now minimized my Expression to the following, but still no live feedback when manipulating.
If I understand correctly, you were saying if it is greater than, do something and if it is less than, do something. But when it is equal to, it won’t do anything.
Would it help if you use “<=” or include an equal to statement?
[QUOTE=clesage;16984]If I understand correctly, you were saying if it is greater than, do something and if it is less than, do something. But when it is equal to, it won’t do anything.
Would it help if you use “<=” or include an equal to statement?[/QUOTE]
This would work nicely, thanks for the idea, however the main problem is knowing how much to move the top cluster to make it the exact length. Right now It go up .01 or .1 so sometimes it would miss the 0 mark and then would be calculated to go back down and ultimately create an infinite loop and i feel if it did end up working that way it would be very inefficient.
I believe (although I am not sure and did not test it) the solution is to not use MEL commands like getAttr/setAttr, as the attributes are not flagged as dirty until the time is changed. Instead, use direct assignment to have it change while manipulating. So instead of saying:
float $CT_top = `getAttr clus_track_top.translateY `;
or
setAttr "clus_track_top.translateY" ($CT_top+$upVal);
use
CT_top = clus_track_top.translateY;
or
clus_track_top.translateY = (CT_top+upVal);
[QUOTE=Phil;17016]I believe (although I am not sure and did not test it) the solution is to not use MEL commands like getAttr/setAttr, as the attributes are not flagged as dirty until the time is changed. Instead, use direct assignment to have it change while manipulating. So instead of saying:
float $CT_top = `getAttr clus_track_top.translateY `;
or
setAttr "clus_track_top.translateY" ($CT_top+$upVal);
use
CT_top = clus_track_top.translateY;
or
clus_track_top.translateY = (CT_top+upVal);
Phil[/QUOTE]
This is just what I was looking for. Thanks Phil!
This is what I have.
There is still a slight stretching of the space between the tread pieces (the sliding is from the timing of the right cluster), but I feel this is fine for the first draft as I’ll be refining it as I continue adding more control.
what is happening in the gif?
So what I’m basically doing is a driven key where the green numbers are the diver and the topcluster.translateY is the driven.
This works great! the only problem is that when I get to creating the controls on the base of the track that will follow the ground terrain/geometry editing the clusters at the bottom will not be able to effect the positioning of the top cluster.
Any feedback or suggestions (or questions) would be grand!