Search code examples
pythonmaya

Maya I want to store in an array


Store the selection of keys that are selected in the image I made as an example. That selection information can be used later to reselect the keys. I want to store in an array to be able to select them later by means of the index.

The script creates the animation keys. How can I select the new keys, either the key before or after the current frame in the timeline?

enter image description here

import maya.cmds as mc

def insertKeyPercentage(percentage = 100):

key1 = mc.currentTime(q = True)

p = 4

key2 = mc.setKeyframe(i = True, t = (key1 +p))
key3 = mc.setKeyframe(i = True, t = (key1 -p))

insertKeyPercentage(percentage = 100)

Solution

  • Have a look at selectKey() it work similiar to the setKeyframe() function.

    key1 = mc.currentTime(q = True)
    mc.selectKey(t=(key1-1, key1+1))