UNSOLVED C4D Freezes after consecutive Import/Export


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")


"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?


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.

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.