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

    C4D Freezes after consecutive Import/Export

    Cinema 4D SDK
    python
    3
    4
    850
    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.
    • orestiskonO
      orestiskon
      last edited by orestiskon

      Hello,

      I'm making a script that converts an FBX to alembic and loads it. It does it as follows:

      1. Load FBX file
      2. Export it as Alembic
      3. Merge the Alembic into current scene

      1 and 2 work fine, but if I try to merge the .abc file then C4D freezes.
      Did I fly too close to the sun with this?

      The code is something like:

      filePath = c4d.storage.LoadDialog(c4d.FILESELECTTYPE_SCENES, "Choose an FBX File", c4d.FILESELECT_LOAD)
      
      fbx = c4d.documents.LoadDocument(filePath, c4d.SCENEFILTER_OBJECTS)
      
      "do some operations in-between"
      
      fileFormat = c4d.FORMAT_ABCEXPORT
      
      savePath = filePath
      savePath.replace(".fbx", ".abc")
      
      c4d.documents.SaveDocument(fbx, savePath, c4d.SAVEDOCUMENTFLAGS_DIALOGSALLOWED | c4d.SAVEDOCUMENTFLAGS_DONTADDTORECENTLIST | c4d.SAVEDOCUMENTFLAGS_NO_SHADERCACHE, fileFormat)
      
      "up to here it's fine, running the one below causes a freeze"
      c4d.documents.MergeDocument(doc, savePath, c4d.SCENEFILTER_OBJECTS)
      
      

      Also, do I need to use KillDocument() for the original FBX which I loaded?

      Thanks!

      orestiskonO 1 Reply Last reply Reply Quote 0
      • orestiskonO
        orestiskon @orestiskon
        last edited by

        @orestiskon
        After debugging the scene, it doesn't seem to freeze now.
        I was using .replace() wrong on the savepath and it caused a conflict.

        Still curious if the killdocument is necessary in the end.

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

          Hi @orestiskon, glad that you fixed your freeze. Replace should not freeze Cinema 4D, I would be interested to have your complete setup to reproduce this freeze.

          KillDocument is needed only if you inserted the document in the list of documents (via c4d.documents.InsertBaseDocument), otherwise the Python Object is the owner of the BaseDocument, and when the Python Garbage Collector will run at the end of your scope, since no more reference of your Python Object (your variable fbx if you prefer) exist, it will delete it, and internally the BaseDocument will be freed properly.

          Cheers,
          Maxime.

          MAXON SDK Specialist

          Development Blog, MAXON Registered Developer

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

            Hello @orestiskon,

            without any further questions, we will consider this topic as solved by Tuesday, November the 2nd and flag it accordingly.

            Thank you for your understanding,
            Ferdinand

            MAXON SDK Specialist
            developers.maxon.net

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