Im not going to tell you how to do this outright, my price is you understanding what it is you are doing to maya. This is very critical maya functionality. You can either accept how maya works or make your life a misery.
QUOTE
(it's not an issue at all for all other 3Dappz I know)
yes but then wed loose mayas arbitrary controll architecture. Wich is the reason we use maya.
QUOTE(ljilekor @ 02/11/08, 12:06 PM) [snapback]280901[/snapback]
I guess the developpers had good reasons not to process everything interactively.
It is possible to do but you have to understand how may works (and when to update). if you dont then you can never pull this one off without understanding the problem.
see maya works on netwrok of connections this i what makes maya so flexible and fast. So a anim curve is connected to your animated attribute etc etc like this.
-> =connection
X> =disabled connection
CODE
anim curve->node
now the reason why asking for the data when you modify the node is futile is because once you move the object maya does what is essentially this:
CODE
anim curve X> manipulator ->node
Now why the hell would they do it like this? Well simply put otherwise the node would be immovable (data set and dirty would cause maya to re-evalueate the anim curve). Now since data moves downstream and since the manipulator data is always clean (actually maya fetches data down up but only becase up down sends dirtyness signals). Now nothing has changed in the enim curve while you moved the node because it dont know what happens.
This leads to a brilliant maya feature, doing manipulation on simple network is allways extremely fast, and you can at any time omit keying your state by just changing time.
Now then why you simply cannot ask for the other time of the anim curve node. Because truly MAYA does not know it yet as no information has changed in the past as nothing is committed yet. Only the local frame has changed not the past.
when you use the setkey command maya fetches the current value in the target slot of and puts it in to the anim curve node. Now this data is available AFTER the key has been set. but your movemen hapopens before. Now what you propose looks something like this.
CODE
+-> anim curve X> node--+
+-----------------------+
Now it doesn't take a rocket scientist to see why this is bad. What would eventually happen is that maya keys EVERY SINGLE frame. Secondly maya would allways spend the extra time to update keyframes wich is a quite heavy operation en masse. Which would kill your performance. (to clarify the above looks like this runtime)
CODE
time -> anim curve -> node-> anim curve
Now you can actually do this however you need to do a bit of massive engineering here. You need to start thinking in a bit larger scale or shall i say time (to be honest i wouldnt do this in mel, but i have in the past and it works). To separate thinking let us first define 3 distinct time zones the animatr experiences:
gui timemanipulation timetime change timeNow the problem is that as far as mayas concerned
manipulation time and
time change time are one and the same thing (playback time). Now the bad news is that
no Script job runs playback time, they are on purpose restricted to gui time only. In fact if you are a programmer and think what script jobs are used for youd be supprised to hear that they are only usefull in keeping guis up to date outside playback. And thus often not what you think they are.
This means you need BOTH a scriptJob and a expression for EVERYTHING you want to listen to. Now then what the hell does the scriptjob do? Well it monitors whats selected, and uses that to enable the expressions one at time when playback mode is initiated, and swithces undo inactive, but not time slider change (to this end you need to mdify the gui hooks). Now the expression does in pseudocode this:
get value with expression language syntax (expressions arent mel) and assigns it to variable.
sets key of the drivien keyframe list
gets the value (yes now you can read it)
uses expression syntax to set a dummy affected net value to a return value thats NOT static eg the variable you asked
now it doesnt work properly, since you just lost undo so what the scriptjob needs to d comming out is to once more key the values and possily time change. And now it works. But yes youll probably end up with problems when bach rendering if yoru not careful.
This said:
theres a easier way, instead of keying back in time key out to another curve that has a offset time this makes for a more manageable system.
CODE
time ---------------->plusminus (-5)------------+ (time)
implicit time->anim curve X> manipulator-> node +> curve 2 -> node 2
Now this has the benfit that you don't need to bacupdate anim curve as the date is forward cahced in node 1 and you don't need to have the scriptjob as yu can just allways push the data with local undo off. A second very good thing si that the expression can be deleted piror to render and jsut fed a copy of original curve wich meake sfor less debug in batch mode. Its also faster for maya to evaluate, but prominently it cannot break the same way as the above.