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

    Converting ABC file to AEC using c4dpy?

    Cinema 4D SDK
    windows python
    2
    3
    370
    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.
    • S
      sophiapreymaker
      last edited by

      Hello, I'm having a bit of trouble figuring out how to convert my ABC file to an AEC file using c4dpy. I wrote a script that works to convert it to a C4D file:

      import c4d
      
      def import_alembic_and_export_c4d(alembic_path):
          # Create a new document
          doc = c4d.documents.BaseDocument()
      
          # Load the Alembic file
          print(alembic_path)
          alembic_file = c4d.documents.LoadDocument(alembic_path, c4d.SCENEFILTER_MERGESCENE)
          if alembic_file is None:
              print("Failed to load Alembic file.")
              return
      
          c4d.documents.LoadFile(alembic_path)
          # Iterate through the objects in the Alembic file and add them to the target document
          for obj in alembic_file.GetObjects():
              doc.InsertObject(obj.Clone(), None, None)
      
           # Set the output path for the AEC file
          c4d_path = alembic_path.replace(".abc", ".c4d")
      
          c4d.documents.SaveDocument(doc, c4d_path, c4d.SAVEDOCUMENTFLAGS_NONE, c4d.FORMAT_C4DEXPORT)
          print(f"Exported C4D file: {c4d_path}")
      
      
      
      if __name__ == "__main__":
          import sys
          import os
          if len(sys.argv) != 2:
              print("Usage: python import_export.py /path/to/alembic.abc")
              sys.exit(1)
      
          alembic_path = sys.argv[1]
          import_alembic_and_export_c4d(alembic_path)
      

      Obviously, this creates a different type than I would like - is it possible to script something similar for creating an AEC file instead? I noticed there's no format option for AEC under saving the document, so I assume it would need to involve rendering instead?

      This would be for Cinema4D 2023 for Windows.

      Thank you!

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

        Hi unfortually the possible way is to render the scene.
        Within Cinema 4D you can call

        rd = doc.GetActiveRenderData()
        rd.Message(c4d.MSG_DESCRIPTION_COMMAND, {"id": c4d.RDATA_PROJECTFILESAVE})
        

        Which will simulate the click on the Save Project File... but this will open a File Selector dialog that you can't script.
        So the only way is to render the scene via c4d.documents.RenderDocument.

        Cheers,
        Maxime.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        1 Reply Last reply Reply Quote 1
        • S
          sophiapreymaker
          last edited by

          Hi Maxime, thanks for the information - so just to clarify, I need to use RDATA_PROJECTFILESAVE in order to export as an AEC?

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