<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Failed to paste keys into Elfenliedtopfan5: time ranges not valid with given option in Maya Programming Forum</title>
    <link>https://forums.autodesk.com/t5/maya-programming-forum/failed-to-paste-keys-into-elfenliedtopfan5-time-ranges-not-valid/m-p/12682589#M439</link>
    <description>&lt;P&gt;Update it wont copy them to the timeline however it does copy the frames if i select the animlayer named elfenliedtopfan5 go to select objects and paste them in it does have the frames but it wont copy them via script for some reason.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 02 Apr 2024 23:15:15 GMT</pubDate>
    <dc:creator>elfenliedtopfan5</dc:creator>
    <dc:date>2024-04-02T23:15:15Z</dc:date>
    <item>
      <title>Failed to paste keys into Elfenliedtopfan5: time ranges not valid with given option</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/failed-to-paste-keys-into-elfenliedtopfan5-time-ranges-not-valid/m-p/12682539#M438</link>
      <description>&lt;P&gt;Good evening all i have this error that is driving me totally insane works fine when i manually try to do this but trying to get this to work with python is driving me crazy&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;below is a video of what i am doing,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;div class="lia-vid-container video-embed-center"&gt;&lt;div id="lia-vid-6350162326112w960h540r432" class="lia-video-brightcove-player-container"&gt;&lt;video-js data-video-id="6350162326112" data-account="6057940548001" data-player="default" data-embed="default" class="vjs-fluid" controls="" data-application-id="" style="width: 100%; height: 100%;"&gt;&lt;/video-js&gt;&lt;/div&gt;&lt;script src="https://players.brightcove.net/6057940548001/default_default/index.min.js"&gt;&lt;/script&gt;&lt;script&gt;(function() {  var wrapper = document.getElementById('lia-vid-6350162326112w960h540r432');  var videoEl = wrapper ? wrapper.querySelector('video-js') : null;  if (videoEl) {     if (window.videojs) {       window.videojs(videoEl).ready(function() {         this.on('loadedmetadata', function() {           this.el().querySelectorAll('.vjs-load-progress div[data-start]').forEach(function(bar) {             bar.setAttribute('role', 'presentation');             bar.setAttribute('aria-hidden', 'true');           });         });       });     }  }})();&lt;/script&gt;&lt;a class="video-embed-link" href="https://forums.autodesk.com/t5/video/gallerypage/video-id/6350162326112"&gt;(view in My Videos)&lt;/a&gt;&lt;/div&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;for the life of me cant figure out why this is doing this here below is what i have&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;def load_idle_and_create_anim_layer(idle_anim_file, min_time_sprint, max_time_sprint):
    # Load the idle animation
    import_se_anim_file(idle_anim_file)
    # Allow a brief pause for the scene to update and for the idle animation to be fully loaded
    time.sleep(0.5)
    cmds.refresh()

    # Set the playback range
    set_playback_range(min_time_sprint, max_time_sprint)

    # Select 'Joints' and its hierarchy to ensure they are included in the animation layer
    cmds.select("Joints", hi=True)

    # Create the animation layer from selected joints
    anim_layer_name = create_idle_anim_layer()

    # Now that the layer is created with the selected joints, add the joints to the layer
    cmds.animLayer(anim_layer_name, edit=True, addSelectedObjects=True)

    # Attempt to paste keys to the newly created animation layer
    paste_keys_to_anim_layer(anim_layer_name, min_time_sprint, max_time_sprint)

    # Final UI refresh to ensure everything is updated
    cmds.refresh()

def create_idle_anim_layer():
    anim_layer_name = "Elfenliedtopfan5"
    
    # Check if the animation layer already exists
    if not cmds.animLayer(anim_layer_name, query=True, exists=True):
        # If it doesn't exist, create the animation layer directly with the name
        anim_layer_name = cmds.animLayer(anim_layer_name)
    else:
        # If it exists, ensure it's unlocked for editing
        cmds.animLayer(anim_layer_name, edit=True, lock=False)

    # The direct approach to make an anim layer current via script might be limited.
    # Therefore, focus on ensuring the layer is available and unlocked for the operations you need to perform.
    
    # Set the necessary attributes for the animation layer
    cmds.setAttr(f"{anim_layer_name}.rotationAccumulationMode", 1)
    cmds.setAttr(f"{anim_layer_name}.scaleAccumulationMode", 1)

    return anim_layer_name
    
def paste_keys_to_anim_layer(anim_layer_name, min_time, max_time):
    # Ensure the animation layer exists and is unlocked
    if cmds.animLayer(anim_layer_name, q=True, ex=True):
        cmds.animLayer(anim_layer_name, e=True, lock=False)
    else:
        print(f"Animation layer '{anim_layer_name}' does not exist.")
        return

    # Attempting to paste keys
    print(f"Attempting to paste keys into {anim_layer_name} from {min_time} to {max_time}")

    # Refresh and ensure UI updates have settled
    cmds.refresh()

    # The actual paste operation
    try:
        # Ensure the animation layer is targeted by making it the only selected object
        cmds.select(anim_layer_name)
        
        # Paste keys with the specified option
        cmds.pasteKey(animLayer=anim_layer_name, time=(min_time, max_time), option="merge")
        
        # Additional refresh after operation to ensure UI reflects changes
        cmds.refresh()
        
        print(f"Successfully pasted keys into {anim_layer_name}.")
    except Exception as e:
        print(f"Failed to paste keys into {anim_layer_name}: {e}")&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;i have tried to comment the parts best i can i not advanced with python only know little bit&amp;nbsp;&lt;/P&gt;&lt;P&gt;but what i am doing here should be work but its failing with the error code&amp;nbsp;&lt;BR /&gt;time ranges not valid with given option&lt;BR /&gt;&lt;BR /&gt;have checked maya createanimlayer documentation that is why i said about the script has limitations but not to this extent should still be able to copy keyframes&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2024 22:43:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/failed-to-paste-keys-into-elfenliedtopfan5-time-ranges-not-valid/m-p/12682539#M438</guid>
      <dc:creator>elfenliedtopfan5</dc:creator>
      <dc:date>2024-04-02T22:43:08Z</dc:date>
    </item>
    <item>
      <title>Re: Failed to paste keys into Elfenliedtopfan5: time ranges not valid with given option</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/failed-to-paste-keys-into-elfenliedtopfan5-time-ranges-not-valid/m-p/12682589#M439</link>
      <description>&lt;P&gt;Update it wont copy them to the timeline however it does copy the frames if i select the animlayer named elfenliedtopfan5 go to select objects and paste them in it does have the frames but it wont copy them via script for some reason.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Apr 2024 23:15:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/failed-to-paste-keys-into-elfenliedtopfan5-time-ranges-not-valid/m-p/12682589#M439</guid>
      <dc:creator>elfenliedtopfan5</dc:creator>
      <dc:date>2024-04-02T23:15:15Z</dc:date>
    </item>
    <item>
      <title>Re: Failed to paste keys into Elfenliedtopfan5: time ranges not valid with given option</title>
      <link>https://forums.autodesk.com/t5/maya-programming-forum/failed-to-paste-keys-into-elfenliedtopfan5-time-ranges-not-valid/m-p/12948787#M440</link>
      <description>&lt;P&gt;I have the same problem and still haven't figured it out.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Aug 2024 08:26:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/maya-programming-forum/failed-to-paste-keys-into-elfenliedtopfan5-time-ranges-not-valid/m-p/12948787#M440</guid>
      <dc:creator>urszula.lawecka6P3SY</dc:creator>
      <dc:date>2024-08-09T08:26:28Z</dc:date>
    </item>
  </channel>
</rss>

