This documentation is for the free plugin Py4D in CINEMA 4D R11.5 and not for the C4DSDK of Python in CINEMA 4D R12. For R12, please visit PluginCafe.com
Here you see a very simple example how to create code which runs in another thread:
from c4d import threading
class MyThread(threading.Thread):
def main(self):
# put in your code here
# which you want to run
# in another thread
pass
thr = MyThread()
thr.start(back=True)
#do some other operations here
thr.wait() #wait until the main method is done
Warning
See Threading information for important information about Threads.
// Methods to call
// Methods to override
Start the thread running.
| Parameters: |
|
|---|
Check if the thread is running.
| Return type: | bool |
|---|---|
| Returns: | True if the thread is running, otherwise False |
Checks if the thread recieved a break command to stop processing.
Note
You can add more break conditions, such as if ESC has been pressed, in test_db_break().
| Return type: | bool |
|---|---|
| Returns: | True if processing should be terminated, otherwise False. |
Override - Checks if the thread recieved a break command to stop processing.
| Return type: | bool |
|---|---|
| Returns: | True if processing should be terminated, otherwise False. |
Override - In this method you can put in your code you want to execute in the threaded context.
Note
Remember that a scope might be done even the threaded code is still executed. In this situation you have to use wait() to wait until the code is finished or you should create an instance of your thread class into a scope which is longer alive than the code needs to run -