Message 1 of 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
The following script moves the keys to the timeline, but it does it in referenced objects without problems, but if these referenced objects have locked keys an error appears, the question is how should be the code to ignore the objects that contain locked keys?
import pymel.core as pm
objects = pm.ls(sl=1)
attrs = pm.selectionConnection('graphEditor1FromOutliner', q=1, object=1)
currentTime = pm.currentTime()
targetAttr = None
if len(attrs) == 1:
buffer = attrs[0].split(".")
if len(buffer) > 1:
targetAttr = buffer[1]
for obj in objects:
attrs = pm.listAttr(obj, keyable=True)
for attr in attrs:
if targetAttr and attr != targetAttr:
continue
nodes = pm.keyframe(obj, attribute=attr, q=True, name=True)
if nodes:
minTime = min(pm.keyframe(obj, attribute=attr, q=True))
pm.keyframe(obj, attribute=attr, edit=True, relative=True, timeChange=currentTime - minTime)
Solved! Go to Solution.