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

    Exporting Motion Clips & what are .c4dsrc Files?

    Cinema 4D SDK
    sdk python
    2
    3
    625
    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.
    • ?
      A Former User
      last edited by

      Hello,
      I have been looking for information regarding Motion Clips on forums and the C4D SDK documentation, but I have only found this article and this article.

      • Is it possible to save and export motion clips with the Python SDK without opening the Motion Clip dialogs with CallCommand?
      c4d.CallCommand(465003044, 465003044) # Add Motion Clip...
      c4d.CallCommand(465003050, 465003050) # Save Motion Source As...
      
      • Is .c4dsrc a Hyperfile/BaseContainer? Can other data be stored in it?

      Thank you.

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

        Hi @blastframe, unfortunately, there is no way to call the command without open the Motion Clips Dialogs.

        However, it's pretty easy to reproduce since it's only retrieving the content of NLA Root (aka where Motion Source are stored see Placing Motion Sources at Timeline Markers with Python - r19.

        So here its what the Save Motion Source do:

        def ExportMotionSource(path, motionSourceObject):
            "motionSourceObject is None to save all MotionSource or pass the returned obj from GetMotionSourceByName"
        
            doc = c4d.documents.GetActiveDocument()
            docNew = c4d.documents.BaseDocument()
        
            # Copy settings
            docNew.SetData(c4d.DOCUMENTSETTINGS_DOCUMENT, doc.GetData(c4d.DOCUMENTSETTINGS_DOCUMENT))
            docNew.SetData(c4d.DOCUMENTSETTINGS_GENERAL, doc.GetData(c4d.DOCUMENTSETTINGS_GENERAL))
        
            docNla = doc.GetNLARoot()
            docNewNla = docNew.GetNLARoot()
        
            if motionSourceObject is None:
                docNla.CopyTo(docNewNla, c4d.COPYFLAGS_NONE, None)
            else:
                copyNewObj = motionSourceObject.GetClone(c4d.COPYFLAGS_NONE, None)
                docNewNla.InsertLast(copyNewObj)
        
            c4d.documents.SaveDocument(docNew, savePath, c4d.SAVEDOCUMENTFLAGS_NONE, c4d.FORMAT_C4DEXPORT)
        
        def LoadExportMotionSource(path):
            doc = c4d.documents.GetActiveDocument()
            c4d.documents.MergeDocument(doc, path, c4d.SCENEFILTER_MERGESCENE, None)
        
        def GetMotionSourceByName(name):
            root = doc.GetNLARoot()
            obj = root.GetDown()
            while obj:
                if obj.GetName() == name:
                    return obj
                obj = obj.GetNext()
        

        Regarding the c4dsrc extension, as you can see internally this is just a BaseDocument saved, the extension is just used to mark this as a motion source file template.

        Cheers,
        Maxime.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        ? 1 Reply Last reply Reply Quote 1
        • ?
          A Former User @m_adam
          last edited by

          @m_adam
          Hi Maxime, thank you for the quick reply and insight into this. I look forward to trying this.

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