Threading Information

All parts of the execution/drawing pipeline of Cinema 4D are threaded. This means that the following methods are called within another thread:

Warning

The document must not be modified in any case (insertion, change order, etc.) inside these methods.
Changing the document structure while an expression is evaluated will crash the application!
As an exception, modifications are allowed that change an object’s parameters like the position or attributes.
So the following functions are forbidden inside expressions (tags/nodes):

ObjectData.GetVirtualObjects() is of course allowed to do any modifications that do not modify the document as the object returned is not in the document at that time it may be created/changed in any way.

Forbidden Functions

For all threaded functions it is forbidden to:

  1. Add an event.
  2. Make any changes to materials.
  3. Change the structure of objects attached to the document.
  4. Change parameters of elements attached to the document. (Allowed, but not recommended except for tags.)
  5. Call a Draw() function.
  6. Perform any GUI functionality. (E.g. displaying messages, opening dialogs etc.)
  7. During drawing to do any file operations. (During execution it is allowed.)
  8. Create undos.

Document Modifications

Before making modifications in the active document, for example from a CommandData dialog, always call StopAllThreads(). Do this even if in the main thread, since there could be other threads that read from the document.