Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Keyframe Selection Code from Cineversity

    Cinema 4D SDK
    r21 python
    2
    3
    398
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B
      bentraje
      last edited by

      Hi,

      I'm trying to use this keyframe selection code from Cineversity..

      I select an object but it prints nothing in the console. It also does not error out. You can see an illustration of the problem here:
      https://www.dropbox.com/s/idwazt6lxg11mcl/c4d146_key_frame_selection.mp4?dl=0

      Should I change something in the code to accommodate possible changes in the Python API?

      1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand
        last edited by

        Hi,

        works fine for me. But the code is missing import statements and a call to main(). Also the indentation is all messed up when you copy the code from their homepage. I just mangled the code through an autopeper, added import and invoked main().

        On a side note: I am not sure if this is code you should learn from. This fine if you just want to get something done. For a learning site I find this unsuitable, but maybe I am to picky.

        import c4d
        
        def GetKeyframeSelection(op):
            """
            """
            if not op or not op.KeyframeSelectionContent():
                return None
        
            keySelection = []
            desc = op.GetDescription(c4d.DESCFLAGS_DESC_0)
        
            for bc, paramid, groupid in desc:
                # print paramid
                # Handle Vectors - seems desc iterator only does top level
                if paramid[0].dtype == c4d.DTYPE_VECTOR:
                    for i in xrange(c4d.VECTOR_X, c4d.VECTOR_Z+1):
                        did = c4d.DescID(
                            paramid[0], c4d.DescLevel(i, c4d.DTYPE_REAL, 0))
                        if op.FindKeyframeSelection(did):
                            keySelection.append(did)
                # Handle top level DescIDs
                elif op.FindKeyframeSelection(paramid):
                    keySelection.append(paramid)
            return keySelection
        
        
        def main():
            """
            """
            keySelection = GetKeyframeSelection(op)
            if keySelection:
                print "*"*4, "Keyframe Select IDs", "*"*4
                print keySelection
        
        
        if __name__ == "__main__":
            main()
        

        Cheers
        zipit

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 1
        • B
          bentraje
          last edited by

          @zipit

          Thanks for the clarification.
          Yea, I guess so but just learning as much as I can.

          Thanks again!

          1 Reply Last reply Reply Quote 0
          • First post
            Last post