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
    • Recent
    • Tags
    • Users
    • Register
    • Login

    MergeDocument() crash C4D

    Scheduled Pinned Locked Moved Cinema 4D SDK
    python2026
    6 Posts 3 Posters 46 Views 2 Watching
    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.
    • chuanzhenC Offline
      chuanzhen
      last edited by

      Hi,

      c4d.documents.MergeDocument(doc, path_str,c4d.SCENEFILTER_OBJECTS | c4d.SCENEFILTER_MATERIALS,None)
      

      this code,c4d always crashed

      相信我,可以的!

      AnlvA 1 Reply Last reply Reply Quote 0
      • AnlvA Offline
        Anlv @chuanzhen
        last edited by Anlv

        Hi, @chuanzhen

        This code runs fine on my end (Cinema 4D 2026.3.4). Analyzing the cause of the failure may require more detailed information, such as the Cinema 4D version number and the real path (path resolution may occur), and corruption of the path_str file is also one possibility.

        Cheers,
        Anlv

        chuanzhenC 1 Reply Last reply Reply Quote 0
        • chuanzhenC Offline
          chuanzhen @Anlv
          last edited by

          @Anlv Hi
          Here is a video demonstrating how C4D crashes. For a saved document (or a loaded document), using MergeDocument() is fine, but for a new document that hasn't been saved, using MergeDocument() will definitely crash
          2026.3.3 win11

          相信我,可以的!

          AnlvA 1 Reply Last reply Reply Quote 0
          • AnlvA Offline
            Anlv @chuanzhen
            last edited by

            Hi, @chuanzhen

            I tested the same code as you in both saved projects and unsaved new documents, but no crash occurred. This might be a bug, possibly related to the ObjectData plugin in your project. I can't be certain that's the cause. You could try ruling out the plugin's influence first. But this is beyond my capability, so let's wait for more professional personnel to help.

            Cheers,
            Anlv

            chuanzhenC 1 Reply Last reply Reply Quote 0
            • chuanzhenC Offline
              chuanzhen @Anlv
              last edited by

              @Anlv Thanks for your reply.can't reproduce this issue on your side, it seems I need to test it on other computers. It's a puzzling problem

              相信我,可以的!

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

                Hey @chuanzhen,

                we will need both the scene you are merging and merging into to make here any sensible statement. We will also need more than this one sole line of code.

                And while a crash always indicates that we could do something better, my hunch would be that that fault lies mostly with some plugin. Because Cinema itself uses heavily MergeDocument and if there would be a principal bug with the very common flags c4d.SCENEFILTER_OBJECTS | c4d.SCENEFILTER_MATERIALS, we would have found and fixed it before.

                The first thing that comes to mind with your line of code is that you are off-main thread and then run into problems because you try to let the code run on the MT by passing None for thread. But off-main-thread, merging documents would be a bit unusual (and also illegal if one of the participating documents is a loaded document). You can use c4d.threading.GeGetCurrentThread() to get the current thread and pass it for thread.

                Another cause could be some NodeData plugin which holds data outside of its data container and which does not correctly serialize that extra data (does not implement NodeData::Read, ::Write, and ::CopyTo) which can then lead to crashes when Cinema tries to run the merged scene with only partially copied node data (assuming the plugin in questions also fails to do sanity/existence checks on its internal extra data).

                Cheers,
                Ferdinand

                MAXON SDK Specialist
                developers.maxon.net

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