View this page "Getting current frame in python"

1,580 views
Skip to first unread message

farsheed

unread,
Dec 17, 2007, 6:05:28 PM12/17/07
to python_inside_maya


Click on http://groups.google.com/group/python_inside_maya/web/getting-current-frame-in-python
- or copy & paste it into your browser's address bar if that doesn't
work.

Dado Feigenblatt

unread,
Dec 17, 2007, 7:00:06 PM12/17/07
to python_in...@googlegroups.com
Hi Farsheed,

You could have written that mel script in python ;)
But why not just do this

import maya.cmds as mc
mc.currentTime(q=1)

Granted, it's not as pretty, but your method is creating an extra node,
that calls the mel interpreter, which then calls the python interpreter.
Then whatever script you write that relies on your method needs to check
if the node already exists, and if it doesn't, create it.

If I really wanted to have a variable pyFrame I would probably make that
in a new python object.
But then we're back to the problem where you need to make sure your maya
nodes and/or python modules are loaded, making your scripts less self
contained and harder to share.

dado

PS: thanks for starting this group.
Even though I've been doing python and mel for a while, I'm just
starting to use python in maya.

farshid ashouri

unread,
Dec 18, 2007, 12:03:24 AM12/18/07
to python_in...@googlegroups.com
Oh, really thanks. but it is based on time (So we need to know our fps) in each scene.
anyway thanks a lot. I learn it and I will add this tip to the page as soon as possible.
Cheers, Farsheed.

Dado Feigenblatt

unread,
Dec 18, 2007, 1:08:47 AM12/18/07
to python_in...@googlegroups.com
Do you mean time unit settings for the project, or actual fps as in
realtime playback speed?
If you need to know the settings, you might try and use this
mc.currentUnit( q=1,time=1 )
I wish it returned just a number and not "film" or "60fps", but at least
it's something we can work with.
For actual playback speed, that I have no idea.

dado

Chadrik

unread,
Dec 18, 2007, 2:41:27 AM12/18/07
to python_inside_maya
and if you're using pymel, as you mentioned you are, you can just do:

from pymel import *
currentTime()

remember, you can do anything in python that you can do in mel, plus
loads more. no need to go back to mel....

...and printing your name every frame might have been over-doing it as
well ;)

farsheed

unread,
Dec 18, 2007, 3:36:25 AM12/18/07
to python_inside_maya
wow, brilliant. Thanks.
Reply all
Reply to author
Forward
0 new messages