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

    Add keyframe to userdata

    Scheduled Pinned Locked Moved PYTHON Development
    3 Posts 0 Posters 545 Views
    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.
    • H Offline
      Helper
      last edited by

      On 18/10/2017 at 00:05, xxxxxxxx wrote:

      I just want to put the keyframe to the userdata, but it does not seem to work.
      So I have doubt if Python does not support to add keyframe to userdata.
      Pls refer to the following script and advise if anything wrong;

      import c4d
      from c4d import gui
      #Welcome to the world of Python

      def main() :
             op = doc.GetActiveObject() #designate the selected object to op

      doc.RecordKey(op,[c4d.ID_BASEOBJECT_REL_ROTATION,c4d.VECTOR_X]) #Add the keyframe to Rotation X successfully
             doc.RecordKey(op,[c4d.ID_USERDATA,1]) #could not add keyframe to userdata

      c4d.EventAdd()

      if __name__=='__main__':
             main()

      JH

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 18/10/2017 at 09:43, xxxxxxxx wrote:

        Hi JH,

        welcome to Plugin Café forums 🙂

        The problem is the DescID provided for the user data. DescIDs are indeed a bit more complex and not in every case the simplified version (as you provided it) is enough.

        If you write it like so, it should work:

        descID = c4d.DescID(c4d.DescLevel(c4d.ID_USERDATA, c4d.DTYPE_SUBCONTAINER, 0), c4d.DescLevel(1, c4d.DTYPE_REAL))
        doc.RecordKey(op,descID)
        

        In our C++ docs we also have a manual about DescIDs, which might be an interesting read for Python developers as well.

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 18/10/2017 at 22:24, xxxxxxxx wrote:

          Great!!
          It works perfect now!

          Thanks a lot!

          JH

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