View Full Version : Change value of a Slider
Camaro 01-13-2010, 10:37 PM Ok, I figured out my last question, but I have a new one, so I figured I'd just edit the same post.
Basically I want to be able to select the closest keyFrame before and after the current Time in the time slider. So if theres a key on frame 2 and frame 16, and I'm on frame 8, how would I tell Maya what the closest keys are?
|
|
thebrianproject
01-14-2010, 04:48 AM
it looks like there's a findKeyframe command in the reference.
you might be able to run a loop with an if statement in it that goes forward and backwards, frame by frame to see if there's a key on that frame, and doesn't stop until it hits a frame with a key on it.
The problem with doing it like this, is that you might end up in an endless loop if there aren't any keys on the object.
Camaro
01-14-2010, 05:05 AM
Well the idea with the script I'm writing is to have an in between and move a slider left or right to favor the key before or after, similar to tradigiTOOLs. (http://funhouseinteractive.biz/tradigitools.html)
Maybe there's another way to do it? Or query if an object has keyframes at all then run a loop?
ewerybody
01-14-2010, 09:26 AM
yea findKeyframe already works context sensitive. If you have a curve selected: It seeks on it. If you have an animated node selected but not a certain curve: It seeks on all connected curves.findKeyframe -w "next";
But to really select the previous and next keys you'd need to know the curves anyhow.keyframe -q -name; can do this for you.
Now a good question: If you have 2 curves selected and the "next" key is on different times on these curves. Shall the tool select only the first that comes? Or on each curve the next key?
Camaro
01-14-2010, 02:25 PM
yea findKeyframe already works context sensitive. If you have a curve selected: It seeks on it. If you have an animated node selected but not a certain curve: It seeks on all connected curves.findKeyframe -w "next";
But to really select the previous and next keys you'd need to know the curves anyhow.keyframe -q -name; can do this for you.
Now a good question: If you have 2 curves selected and the "next" key is on different times on these curves. Shall the tool select only the first that comes? Or on each curve the next key?
Thanks for that, I'll have to do a lot of experimenting to get it to work in any case. As for your question: ideally the second option would be best, and thus I would have to write the program to do the same procedure separately for each selected object. I'm glad you asked that because I probably wouldn't have thought of it.
ewerybody
01-14-2010, 02:44 PM
sorry ... :rolleyes: I just thought about it. Quite easy:
{
selectKey -clear;
string $selCurves[] = `keyframe -q -name`;
for ($curve in $selCurves)
{
selectKey -add -t (`findKeyframe -w "next" $curve`)$curve;
selectKey -add -t (`findKeyframe -w "previous" $curve`)$curve;
}
}
CGTalk Moderation
01-14-2010, 02:44 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.