Error: TypeError: file <maya console> line 1: Invalid arguments for flag 'time'. Expected (time, [time]), got float

1,110 views
Skip to first unread message

Besjan Xhika

unread,
Apr 10, 2012, 2:15:24 PM4/10/12
to python_in...@googlegroups.com
Hi, I'm studying Maya programming..
and got around this error while trying to convert a MEL script to a Python script..

MEL

float $keytimes[];
$keytimes = `keyframe -query -timeChange nurbsSphere1_translateX`;
// Result: 1 48 //
$keyt =  $keytimes[0];
// Result: 1 //
keyframe -time $keyt -query -valueChange nurbsSphere1_translateX;
// Result: -5.321007 // 

nurbsSphere1_translateX is an animation curve..
// Result: 1 48 // are two frames that have keys..

In MEL works OK.
**************************************************
Python

keytimes = cmds.keyframe('nurbsSphere1_translateX', query = True, timeChange = True)

# Result: [1.0, 48.0] #

keyt = keytimes[0]

# Result: 1.0 #

cmds.keyframe('nurbsSphere1_translateX', time = keyt, query = True, valueChange = True)

# Error: TypeError: file <maya console> line 1: Invalid arguments for flag 'time'. Expected (time, [time]), got float #


In Python doesn't work..

So $keyt = 1 and keyt = 1.0 should be the same (floats)..

While in MEL is accepting a float for time (maybe is being converted automatically, or something..), in Python is not..

Anyone got any idea?

damon shelton

unread,
Apr 12, 2012, 8:26:09 PM4/12/12
to python_in...@googlegroups.com
in python time is required as a start and end time
keyt = (keytimes[0], keytimes[0])

cmds.keyframe('nurbsSphere1_translateX', time = keyt, query = True, valueChange = True)


Besjan Xhika

unread,
Apr 22, 2012, 5:36:27 AM4/22/12
to python_in...@googlegroups.com
Thanks for your reply, I found the solution soon after I posted in here.


On Friday, April 13, 2012 2:26:09 AM UTC+2, damonshelton wrote:
in python time is required as a start and end time
keyt = (keytimes[0], keytimes[0])
cmds.keyframe('nurbsSphere1_translateX', time = keyt, query = True, valueChange = True)

Justin Israel

unread,
Apr 22, 2012, 1:56:38 PM4/22/12
to python_in...@googlegroups.com
Hey Besjan,

It might be a good idea to follow up on your questions if you ask the community something and then someone answers. I keep seeing a pattern in this discussion group where people will ask a question, someone takes the time to provide information, and then that original person says nothing about it for maybe a week or never. In your case, you stated you solved this soon after posting. Closing this thread would prevent someone else from putting time into it for you, or might help someone else that comes across this in the meantime.

I feel like we need to address the Q&A etiquette situation here on this group. Am I wrong anyone? Just a thought.

-- justin

Besjan Xhika

unread,
Apr 22, 2012, 3:55:49 PM4/22/12
to python_in...@googlegroups.com
You're right. I wanted to reply after I founded the solution but I couldn't find my post and I thought it was deleted and didn't checked for it anymore, until now.
Reply all
Reply to author
Forward
0 new messages