PDA

View Full Version : how do i make a function that calculates on every frame


Agent X
10-19-2008, 11:17 AM
Hey guys,

quick synopsis:
how do i make a function that calculates on every frame (like AS3 on enterframe)?


long diatribe:
i have been asked to rig a rubik's cube for work, and i have 90% of it down, but one of the last things i need to figure out is important and, i have no idea on how to do it.

How do i get maya to run a function on every frame?

TIA

bendingiscool
10-19-2008, 07:15 PM
sounds like you could use a script job, with the -timeChange flag.

Sorry can't be much more useful but do not know much about it, just that it sounds like something you may want to look into.

Chris

Buexe
10-20-2008, 09:04 AM
and what about an expression?

DOor
10-20-2008, 03:30 PM
you dont need scriptjob for this.

as mentioned above an expression may be what you are looking for.. if this is not a viable option then the following is what I would do to run a command for a set of key frames within a mel script.

first, determine the number of key frames you need to calculate on (0 to whatever). use these numbers to create a procedure that has a loop and will call the function you want for each keyframe.

now I am not sure what type of data your function is grabbing BUT when accesing data such as rotations, translations, etc it will pull the time from the current time OR if you use the getAttr command you can specify a time with the -t flag. (this will make the script run faster since it does not have to update the model editor.)

if you need to change the current time you should do so before you call the function in your loop using the currentTime command.



I think this should help your issue, if something is still confusing let me know.

Agent X
10-20-2008, 10:56 PM
Thanks guys, I'll report back with how it went. My basic idea was to apply and remove constraints on the cubes when the controls move. Thanks for the help!

CGTalk Moderation
10-20-2008, 10:56 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.