Last active
May 1, 2020 16:16
-
-
Save chris-gardner/b5ec333e86da021a0df3167f9e06ecb7 to your computer and use it in GitHub Desktop.
Filters static keyframes in Houdini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hou | |
if hou.selectedNodes(): | |
nd = hou.selectedNodes()[0] | |
else: | |
nd = hou.node("/") | |
nodeArr = nd.allSubChildren() | |
for n in nodeArr: | |
if not n.isInsideLockedHDA(): | |
parmArr = n.parms() | |
for p in parmArr: | |
if p.isTimeDependent(): | |
#print p | |
deletelist = [] | |
keyframes = p.keyframes() | |
if len(keyframes) > 1: | |
lastkey = None | |
blockstart = None | |
for key in keyframes: | |
if lastkey: | |
if key.value() == lastkey.value(): | |
if blockstart is None: | |
blockstart = True | |
#print 'blockstart at', lastkey.frame() | |
if blockstart is not True: | |
deletelist.append(lastkey.frame()) | |
else: | |
blockstart = None | |
if blockstart is True: | |
lastkey.setExpression("linear()", hou.exprLanguage.Hscript) | |
p.setKeyframe(lastkey) | |
blockstart = False | |
# first frame - ignore | |
lastkey = key | |
for frame in deletelist: | |
p.deleteKeyframeAtFrame(frame) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment