How to find out if document is rendering from a python tag
-
Hello guys,
how can I find out if a document is rendering? I tried the following code with mixed results.
What works for me is the following.
All of these methods returnTrue
if their respective task runs.c4d.documents.GetBatchRender() print(batch.IsRendering()) print(c4d.CheckIsRunning(c4d.CHECKISRUNNING_EXTERNALRENDERING)) print(c4d.modules.takesystem.IsTakeRenderRunning())
What does not work are the following methods which simply return always
0
print(c4d.CheckIsRunning(c4d.CHECKISRUNNING_EDITORRENDERING)) print(c4d.CheckIsRunning(c4d.CHECKISRUNNING_INTERACTIVERENDERING)
I'm using all of this inside
def main()
of a python tag if that helps.Cheers,
Sebastian -
Hi @HerrMay sadly having something working within the
main
will be a bit tricky, but this can be easily tested with message and more especially the MSG_MULTI_RENDERNOTIFICATIONFind below a script run from a Python Tag.
from typing import Optional import c4d doc: c4d.documents.BaseDocument # The document evaluating this tag op: c4d.BaseTag # The Python scripting tag flags: int # c4d.EXECUTIONFLAGS priority: int # c4d.EXECUTIONPRIORITY tp: Optional[c4d.modules.thinkingparticles.TP_MasterSystem] # Particle system thread: Optional[c4d.threading.BaseThread] # The thread executing this tag def main() -> None: # Called when the tag is executed. It can be called multiple time per frame. Similar to TagData.Execute. # Write your code here pass def message(id: int, data: object) -> bool: if id == c4d.MSG_MULTI_RENDERNOTIFICATION and data["start"]: print(data) return True
Note that the MSG_MULTI_RENDERNOTIFICATION in Python does not contain the context from which a render was started via the flag argument as it is in C++. I added it, so it will be in one of the next version of Cinema 4D.
Finally note that some IPR from external render engine may not work, as they bypass completely the Cinema 4D rendering pipeline.Cheers,
Maxime. -
Hi @m_adam,
thanks for the explanation and your example code. That will absolutely suffice my needs.
Good to know though that additional information may be available in the future.
Cheers,
Sebastian -