cmds.selectKey "Expected (time [time]), got int

118 views
Skip to first unread message

john patterson

unread,
Mar 25, 2018, 3:40:53 PM3/25/18
to Python Programming for Autodesk Maya
Can someone please translate this MEL to Python?  I am not using pyMEL.

selectKey -add -k -t 1 -t 9 -t 17 -t 25 -t 33 -t 41 pSphere1_translateY ;

The docs say that a single time is acceptable, or a range.  I can't even get this to work...

cmds.selectKey("pSphere1.translateY", add=1, k=1,t=1)

I don't mind writing 6 lines of Python for those 6 different times.  Anyone?  

Justin Israel

unread,
Mar 25, 2018, 5:08:46 PM3/25/18
to python_in...@googlegroups.com
Did you check the docs? There are examples at the bottom. The time parameter expects a python tuple, since python functions cant accept multiple uses of the same parameter name, like in Mel


Try
cmds.selectKey("pSphere1.translateY", add=True, k=True, t=(1,)
cmds.selectKey("pSphere1.translateY", add=True, k=True, t=(1, 9, 17, 25, 33, 41)

The part of that doc that isn't very clear is that it pretends to support more variations of that time value than it actually does. Sometimes the python docs were copied from Mel without fully updating. 


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/ac118da8-9795-4095-bae0-aaab344edac5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

john patterson

unread,
Mar 28, 2018, 1:33:42 PM3/28/18
to Python Programming for Autodesk Maya
Thanks for the reply.  Yes, I read the documentation.  It was not helpful.  I read the specs for the time flag, (quoted below), which are wrong.  It says that single values are valid, but it doesn't say that even a single value has to be in a tuple, and shows a misleading example that looks like MEL....

"""

time(t) timerange createmultiuse
time uniquely representing a key (or key range) on a time-based animCurve. Valid timeRanges include single values (-t 10) or a string with a lower and upper bound, separated by a colon (-t "10:20")
In query mode, this flag needs a value.

"""


Your examples would be a great addition to the doc page.



On Sunday, March 25, 2018 at 5:08:46 PM UTC-4, Justin Israel wrote:


On Mon, Mar 26, 2018, 8:40 AM john patterson <0.j...@gmail.com> wrote:
Can someone please translate this MEL to Python?  I am not using pyMEL.

selectKey -add -k -t 1 -t 9 -t 17 -t 25 -t 33 -t 41 pSphere1_translateY ;

The docs say that a single time is acceptable, or a range.  I can't even get this to work...

cmds.selectKey("pSphere1.translateY", add=1, k=1,t=1)

I don't mind writing 6 lines of Python for those 6 different times.  Anyone?  


Did you check the docs? There are examples at the bottom. The time parameter expects a python tuple, since python functions cant accept multiple uses of the same parameter name, like in Mel


Try
cmds.selectKey("pSphere1.translateY", add=True, k=True, t=(1,)
cmds.selectKey("pSphere1.translateY", add=True, k=True, t=(1, 9, 17, 25, 33, 41)

The part of that doc that isn't very clear is that it pretends to support more variations of that time value than it actually does. Sometimes the python docs were copied from Mel without fully updating. 


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

Justin Israel

unread,
Mar 28, 2018, 2:21:45 PM3/28/18
to python_in...@googlegroups.com


On Thu, Mar 29, 2018, 6:33 AM john patterson <0.j...@gmail.com> wrote:
Thanks for the reply.  Yes, I read the documentation.  It was not helpful.  I read the specs for the time flag, (quoted below), which are wrong.  It says that single values are valid, but it doesn't say that even a single value has to be in a tuple, and shows a misleading example that looks like MEL....

"""

time(t) timerange createmultiuse
time uniquely representing a key (or key range) on a time-based animCurve. Valid timeRanges include single values (-t 10) or a string with a lower and upper bound, separated by a colon (-t "10:20")
In query mode, this flag needs a value.

"""


Your examples would be a great addition to the doc page.

Yea like I said their docs are incomplete and wrong. But they do have examples of multiple time values at the bottom. What they are missing is the example of the single value still being passed in a tuple. 




On Sunday, March 25, 2018 at 5:08:46 PM UTC-4, Justin Israel wrote:


On Mon, Mar 26, 2018, 8:40 AM john patterson <0.j...@gmail.com> wrote:
Can someone please translate this MEL to Python?  I am not using pyMEL.

selectKey -add -k -t 1 -t 9 -t 17 -t 25 -t 33 -t 41 pSphere1_translateY ;

The docs say that a single time is acceptable, or a range.  I can't even get this to work...

cmds.selectKey("pSphere1.translateY", add=1, k=1,t=1)

I don't mind writing 6 lines of Python for those 6 different times.  Anyone?  


Did you check the docs? There are examples at the bottom. The time parameter expects a python tuple, since python functions cant accept multiple uses of the same parameter name, like in Mel


Try
cmds.selectKey("pSphere1.translateY", add=True, k=True, t=(1,)
cmds.selectKey("pSphere1.translateY", add=True, k=True, t=(1, 9, 17, 25, 33, 41)

The part of that doc that isn't very clear is that it pretends to support more variations of that time value than it actually does. Sometimes the python docs were copied from Mel without fully updating. 


--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/a178fbb5-0353-4a4e-ae6f-631b874f8217%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages