Message 1 of 3
Failed to paste keys into Elfenliedtopfan5: time ranges not valid with given option
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
below is a video of what i am doing,
for the life of me cant figure out why this is doing this here below is what i have
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}")
i have tried to comment the parts best i can i not advanced with python only know little bit
but what i am doing here should be work but its failing with the error code
time ranges not valid with given option
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