Moving animation keys in python or hscript

   1162   1   0
User Avatar
Member
20 posts
Joined: Oct. 2016
Offline
I am writing a small animation tool that moves animation keys around. I am using “chkeymv” hscript command to do that. It works fine but I simply cannot retain the original user key selection in the animation editor. The selection always changes after.
I have also tried using python hou.Keyframe class by calling setFrame and calling hou.Parm.setKeyframe() and then deleting the old key but of course the selection also can't be retained.

Is there any way to retain the original key selection after calling “chkeymv” or is there any way to make Animation Editor keyframe selection in Python or Hscript?

Thanks in advance.

Rok Andic
www.rokandic.com
User Avatar
Member
1 posts
Joined: June 2019
Offline
Hello,

I tried to use hou.setFrame() to extract the values of the Detail/Global Attributes changing with each frame in a text file but python doesn't seem to update these values. Moreover it appears to launch several times the script linked to the size of the loop.

If someone have a solution and can explain to me why this doesn't work, I would be more than grateful.
Bests regards,
Tiber


——————————————————
node = hou.pwd()
geo = node.geometry()

# CONFIG
filename = "/home/DetailAttribs.txt"
separator = ";"

# Set Frame
for frame in range(1,500,1):
    hou.setFrame(frame)

    if hou.intFrame() == 1:
        # Get File
        f = file(filename, "w")
        # Insert Columns
        for attrib in geo.globalAttribs():
            if (attrib.name() == "ModifiedCamClay") or (attrib.name() == "P"):
                attrib_count = attrib.size()
                if 1 != attrib_count:
                    for i in range(0,attrib_count):
                        if i > 2:   # if its a Multi Array
                            f.write(attrib.name() + "[" + chr(94 + i) + "]" + separator) # ASCII to Char 
                        else:
                            f.write(attrib.name() + "[" + chr(88 + i) + "]" + separator) # ASCII to Char 
                    
                else:
                    f.write(attrib.name())
                    f.write(separator)
        f.write("\n")
    else:
        # hou.node('/obj/alembic1/').cook(force=True)
        # Get File
        f = file(filename, "a")
        # Insert AttribsValue
        for attrib in geo.globalAttribs():
            if (attrib.name() == "ModifiedCamClay") or (attrib.name() == "P"):
                attrib_count = attrib.size()
                if 1 != attrib_count:
                    for i in range(0,attrib_count):
                        f.write(str(geo.attribValue(attrib)[i]) + separator)
                else:
                    f.write(str(geo.attribValue(attrib)))
                    f.write(separator)
        f.write("\n")
  • Quick Links