Hi Justin, Thanks for the reply. Yes, float_value is not needed. I was getting error when I was passing it as tuple or string. But the problem is solved now. I was using Pycharm and I had multiple windows open. For some reason, it was reading a scene from another window where there were no keys and it keep giving me errors. After closing the other window, it worked as it is supposed to.
Thanks once again :). On Mon, Jun 28, 2021 at 8:20 PM Justin Israel <justinisr...@gmail.com> wrote: > > > On Mon, Jun 28, 2021 at 11:51 PM Utkarsh Agnihotri <utkarsh6...@gmail.com> > wrote: > >> Hi everyone, >> I am trying to copy keys from imported rig and paste it to the reference >> rig. I have written following code: >> >> ``` import pymel.core as pm >> >> # select the ctrls to copy keys >> sel = pm.ls("*CTRL") >> >> print(sel) >> >> # get a list of references >> refs = pm.listReferences() >> >> reference_namespaces = [] >> >> # get list of namespaces from reference >> for ref in refs: >> reference_namespaces.append(ref.namespace) >> >> # get time slider range of the scene >> min_timeRange = pm.playbackOptions(q=1, min=1) >> max_timeRange = pm.playbackOptions(q=1, max=1) >> >> time_value = "{}:{}".format(min_timeRange, max_timeRange) >> float_value = "{}:{}".format(min_timeRange, max_timeRange) >> >> for s in sel: >> pm.copyKey(s, time=":", hierarchy="none", controlPoints=0, shape=1) >> for reference_namespace in reference_namespaces: >> if pm.objExists(reference_namespace + ":" + s): >> referenced_ctrl = reference_namespace + ":" + s >> pm.pasteKey(referenced_ctrl, option="replaceCompletely", >> float=(min_timeRange, max_timeRange), >> time=(min_timeRange, max_timeRange), copies=1, >> connect=0)``` >> >> It is showing me following error: >> # Traceback (most recent call last): >> # File "<maya console>", line 1, in <module> >> # File >> "D:/Downloads/Scripts/Scripts/utkarsh/daily_scripts/transferKeys.py", line >> 29, in <module> >> # pm.pasteKey(referenced_ctrl, option="replaceCompletely", >> time=(min_timeRange, max_timeRange)) >> # File "C:\Program >> Files\Autodesk\Maya2020\Python\lib\site-packages\pymel\core\animation.py", >> line 754, in pasteKey >> # res = cmds.pasteKey(*args, **kwargs) >> # File "C:\Program >> Files\Autodesk\Maya2020\Python\lib\site-packages\pymel\internal\pmcmds.py", >> line 130, in pasteKey_wrapped >> # res = new_cmd(*new_args, **new_kwargs) >> # RuntimeError: time ranges not valid with given option # >> >> pastekey command seems to be the main issue and I checked with command >> page. I understand what is wrong with the command. >> Please help!! >> > > You have created these identical formatted strings: > > time_value = "{}:{}".format(min_timeRange, max_timeRange) > float_value = "{}:{}".format(min_timeRange, max_timeRange) > > But you never used them: > > pm.pasteKey(referenced_ctrl, option="replaceCompletely", > float=(min_timeRange, max_timeRange), > time=(min_timeRange, max_timeRange), copies=1, > connect=0) > > Did you mean to pass time_value or float_value to the float/time > parameters instead of the tuples? > > >> >> >> -- >> 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+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/python_inside_maya/c920bd24-d2dc-4218-9e17-47e56a469ed0n%40googlegroups.com >> <https://groups.google.com/d/msgid/python_inside_maya/c920bd24-d2dc-4218-9e17-47e56a469ed0n%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- > You received this message because you are subscribed to a topic in the > Google Groups "Python Programming for Autodesk Maya" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/python_inside_maya/DlgUhUYD6yo/unsubscribe > . > To unsubscribe from this group and all its topics, send an email to > python_inside_maya+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA34ByLx%2Bh0zw8mLVbh%3DW5ToTujvFSgkP-o%3D_j_030ZWnQ%40mail.gmail.com > <https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA34ByLx%2Bh0zw8mLVbh%3DW5ToTujvFSgkP-o%3D_j_030ZWnQ%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPCRbh9BF6082GQLm%3D0BTd%2BFx-wowiCX55BeFQ6psFvae%2BUO9A%40mail.gmail.com.