The Smart Delete Key cannot delete a key that has been set using the Key > Set Key or Insert Key functions.

The Smart Delete Key cannot delete a key that has been set using the Key > Set Key or Insert Key functions.

amaterasu-qbb
Collaborator Collaborator
96 Views
0 Replies
Message 1 of 1

The Smart Delete Key cannot delete a key that has been set using the Key > Set Key or Insert Key functions.

amaterasu-qbb
Collaborator
Collaborator
When the Smart Set Key is executed, the key is set to the currently selected channel (graph) if a channel has been selected.
Otherwise, it sets the key to all channels (graphs).

The code is as follows:
# Smart Set Key

import maya.cmds as cmds

# Get current time
current_time = cmds.currentTime(query=True)

# Get selected curves in Graph Editor
selected_curves = cmds.keyframe(query=True, selected=True, name=True)

if selected_curves:
    # Key only selected curves
    for curve in selected_curves:
        value = cmds.keyframe(curve, query=True, eval=True, time=(current_time,))[0]
        cmds.setKeyframe(curve, time=current_time, value=value)
    print(f"Keyed selected curves at frame {current_time}")
else:
    # No selected curves ? key all animated attributes of selected object(s)
    selected_objs = cmds.ls(selection=True)
    if selected_objs:
        for obj in selected_objs:
            anim_attrs = cmds.listAnimatable(obj) or []
            for attr in anim_attrs:
                cmds.setKeyframe(attr, time=current_time)
        print(f"Keyed all animated channels of selected objects at frame {current_time}")
    else:
        print("No objects selected.")
Smart Set keyed keys can be deleted with the Smart Delete key without any problem. It's not possible with Key>Set Key, Insert Key.

The following functions are planned for Smart Delete Keys: If a channel is selected, the key of the currently selected channel (graph) will be deleted.
If no channel is selected, all channel keys will be deleted.

The code is as follows:
# Smart Delete Key

import maya.cmds as cmds

# Get current time
current_time = cmds.currentTime(query=True)

# Get selected animation curves in Graph Editor
selected_curves = cmds.keyframe(query=True, selected=True, name=True)

if selected_curves:
    # Delete key only from selected curves at current frame
    for curve in selected_curves:
        cmds.cutKey(curve, time=(current_time, current_time), option="keys")
    print(f"Deleted key from selected curves at frame {current_time}")
else:
    # No curve selected: delete all keys at current frame from all animated attributes
    selected_objs = cmds.ls(selection=True)
    if selected_objs:
        for obj in selected_objs:
            anim_attrs = cmds.listAnimatable(obj) or []
            for attr in anim_attrs:
                cmds.cutKey(attr, time=(current_time, current_time), option="keys")
        print(f"Deleted keys from all animated channels of selected objects at frame {current_time}")
    else:
        print("No objects selected.")
Default Set key code:
setKeyframe -breakdown 0 -preserveCurveShape 0 -hierarchy none -controlPoints 0 -shape 0 {"camera1_group", "Ultimate_Ball_v1_0_1:AniM_ball_Main", "Ultimate_Ball_v1_0_1:CTRL_Main_motionTrail"};
Default Insert key code:
InsertKey;
Code when Delete is pressed by default:
doDelete;
// C:/Program Files/Autodesk/MayaCreative2025/scripts/others/doDelete.mel
Code when Delete Key is executed by default:
DeleteKeys;
// Run time command
 
any advice would be appreciated.
Thanks.
0 Likes
97 Views
0 Replies
Replies (0)