Maya Stand Alone, Recording Values Over Time

How would i record the values of attribute over time?

I was told that with Maya Standalone, you don’t have access to Mayas UI elements because that aren’t loaded/ don’t exist. So if I wanted to record the position of a constrained object from a certain time range ie( 1-20) how would I achieve this? Since I can’t use the cmds.currentTime() command to update the time in the scene file? And bakeResult only bakes out the first frame of the object…

getAttr has a flag called Time, see if that does the trick “Evaluate the attribute at the given time instead of the current time.”

Also, I have managed to use listconnections to get hold of the animation node of a ‘set driven key’ once and was able to grab values out of the curves of that anim-node.
Gonna check if I can find some of that code and post it.

Or get the time node in your scene. And see if you can manipulate current time directly from it.

cmds.ls( type = "time" )

Arite thank you, what is the best way of running maya standalone? i’ve been making a bat file and executing it that way, but when I try that same method on other computers it crashes

Try setting the time with MGlobal::viewFrame

OpenMaya.MGlobal.viewFrame(15.0) #etc

I generally just drop a .py file onto mayapy.exe to do batch mode, or launch it and enter commands by hand.

If you want to be able to call a standalone instance from a tool you can open mayapy.exe using subprocess or os.sytem and then pass the .py file you want to run as a command arg, as well as args for the .py file like so.

cmd = 'mayapy somePyFile.py arg1 arg2 arg3'
os.system(cmd)

#or

subprocess.call(cmd) 

in the .py file you can code as if you were in maya, just make sure you have the following in there

import maya.standalone as ms

ms.initialize(name='python')

Matt - That maya.standalone import thing is new to me. Why is it necessary? I thought you could just plop some python in a file and mayapy would execute it as expected…?

You have to import maya standalone and initialize it to boot up the maya core, otherwise importing and using maya cmds/OpenMaya/mel will fail.