Threading Manual¶
All parts of the execution/drawing pipeline of Cinema 4D are threaded. This means that the following methods are called within another thread:
ObjectData.GetVirtualObjects()
ObjectData.Execute()
ObjectData.Draw()
ObjectData.DrawShadow()
other Draw() / Execute()
All objects that embbed Python such as the python generator, python tag, python effector, python field.
Warning
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:
Add an event.
Make any changes to materials.
Change the structure of objects attached to the document.
Change parameters of elements attached to the document. (Allowed, but not recommended except for tags.)
Call a Draw() function.
Perform any GUI functionality. (E.g. displaying messages, opening dialogs etc.)
During drawing to do any file operations. (During execution it is allowed.)
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.