Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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

    Access Bake Objects (Timeline) or Bake Animation to Curves

    Cinema 4D SDK
    r20 python
    3
    4
    986
    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 bake my animation into curves, currently, they are either driven by procedural animation (e.g. vibrate tag) or by a PSR tag.

      However, I don't see any details about the baking option in the documentation. It's either BakeTexture or BakeWeights. Same goes with the topics here in the forum.

      There is a thread about baking curves here. I appreciate the recreation of the code for the baking procedure, but I just need to just access the bake texture dialog box, so I can save myself from debugging.

      You can see what I am trying to access here:
      https://www.dropbox.com/s/yn0fb49p290veut/c4d126_access_bake_object_python.png?dl=0

      Is there a way around this?

      Thank you for looking at my problem.

      1 Reply Last reply Reply Quote 0
      • lasselauchL
        lasselauch
        last edited by lasselauch

        Hi @bentraje,

        The thread about baking curves is still the right way to go if you want to be exact and want to bake other properties than PSR.

        However, if you're just interested in baking only your PSR, you can use doc.Record(), this works on all selected Objects since R19. You can take a look at the following example for baking Cubes with a Vibrate-Tag for example...:

        import c4d
        
        #https://developers.maxon.net/docs/py/2023_2/modules/c4d.documents/BaseDocument/index.html?highlight=executepasses#BaseDocument.ExecutePasses
        def SetCurrentTime(currentTime, doc):
            doc.SetTime(currentTime)
            doc.ExecutePasses(None, True, True, False, 0)    
        
        def main():
            minTime = doc[c4d.DOCUMENT_MINTIME]
            maxTime = doc[c4d.DOCUMENT_MAXTIME]
            fps = doc.GetFps()
            
            if minTime != maxTime:
                currentTime = minTime
                while (currentTime <= maxTime): 
                    SetCurrentTime(currentTime, doc)
                    print "Baking: Frame: %s" %(currentTime.GetFrame(fps))
                    
                    #New since version R19.
                    #Records the active objects in the document.
                    doc.Record()
                    
                    currentTime += c4d.BaseTime(1, fps)
        
        if __name__=='__main__':
            main()
        

        Oh, and accessing the "Bake Objects..." Dialog via Python is not possible!

        1 Reply Last reply Reply Quote 4
        • M
          m_adam
          last edited by

          Hi @bentraje,

          Actually, this is not possible as @lasselauch demonstrate you, the only way is to do it manually.

          Cheers,
          Maxime.

          MAXON SDK Specialist

          Development Blog, MAXON Registered Developer

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

            @lasselauch

            I guess I need to revisit the script in the link above when I need to bake user data. Anyway, your script will do at the moment. It's readable enough for my newbie eyes 🙂 It works as I expected!

            Thanks for the handy script.

            @m_adam

            Thanks for the confirmation!

            1 Reply Last reply Reply Quote 0
            • i_mazlovI i_mazlov forked this topic on
            • First post
              Last post