Listening to the status of the Pictureviewer (like when Rendering Multiple Takes to Pictureviewer)
-
Hello,
Is it possible to listen to when a render has been completed in the Pictureviewer? I'm using the "render takes to pictureviewer" command to export a series of ORBX files. Once they're done exporting I would like run a function.
I can't use the batchrenderer because I'm exporting multiple ORBX files by "rendering" multiple takes to the PictureViewer. This is the only way currently to automate this process - in the batchrender it keeps getting stopped by a dialogbox that "saving the file" needs to be enabled (but it actually needs to be oiff, because I do not want to render anything, just export) and then the "render" aborts.
Thanks in any case!
-
Hey @GillesKontrol,
Thank you for reaching out to us. There probably does unfortunately not exist a good solution for this problem of yours either.
There is the message MSG_MULTI_RENDERNOTIFICATION which does in principle what you want there are however two problems:
- Only the C++ variant contains the
RENDERFLAGS
field which would let you allow to detect if the rendering happend in the Picture Viewer, and not for example in the viewport. In Python you can detect a finished rendering, but not its "place". MSG_MULTI_RENDERNOTIFICATION
is a node message which means that you need access to some kind of node implementation. What you are doing sounds more like a script or command plugin, where you do not have access to that message stream.
Cheers,
Ferdinand - Only the C++ variant contains the
-
Thankyou Ferdinand!
It is a script for now but I will integrate it in a commandplugin so haha, bad luck on both those counts!
Could you point me to a function or example of how I can detect a finished rendering? I might be able to check X number of times for a finished rendering and then execute the function. It's not perfect but it might do the trick for now.Thanks for the response, very helpful insights!
Best regards,
-
Hey @GillesKontrol,
as I said, the message
MSG_MULTI_RENDERNOTIFICATION
is an atom/node message. So, there is no easy way for you to use it, since you do not implement a node.You need either a plugin hook which derrives from
NodeData
and therefore can implementNodeData::Message
or one of the scripting objects as for example the Python Generator object or the Python tag which implement amessage
method (which is just a thin wrapper arroundNodeData::Message
). See Python API: Message Manual for details on the message system.Implementation-wise there is not really much to it, you just listen for the mesage and then look at the message data. Here is a very simple example in the context of a Python Generator object:
import c4d import pprint def main() -> c4d.BaseObject: """Irrelevant for the example. """ return c4d.BaseObject(c4d.Onull) def message(mid: int, data: object) -> bool: """Called by Cinema 4D to convey events to the node. """ if mid == c4d.MSG_MULTI_RENDERNOTIFICATION: print (f"Render event:\n{pprint.pformat(data)}") return True
Scene file: render_notification.c4d
When I then first started a picture viewer rendering and then an editor rendering, the output has been as follows (note that only editor renderings have start and end events, PV renderings just end):
Render event: {'animated': False, 'doc': <c4d.documents.BaseDocument object called with ID 110059 at 140163486535680>, 'external': True, 'render': <capsule object "render" at 0x7f7a5a944300>, 'start': False} Render event: {'animated': False, 'doc': <c4d.documents.BaseDocument object called with ID 110059 at 140163836713408>, 'external': False, 'render': <capsule object "render" at 0x7f7a6f294a00>, 'start': True} Render event: {'animated': False, 'doc': <c4d.documents.BaseDocument object called with ID 110059 at 140163836720896>, 'external': False, 'render': <capsule object "render" at 0x7f7a6f284d00>, 'start': False}
For more information about the event data I would suggest reading the links I have provided above. You can either place a dummy node in your scene which propagtes such information to a command data plugin, or just setup shop in a
TagData
plugin or a Python scripting tag in the first place. I.e., you add a button to your tag and when the user presses that button, you execute your "command script". The actualTagData::Excute
method or themain
method of a Python tag would then remain an unused dummy implementation, just as in my little example. But just as in my example, you would then also have access to the node message stream.Cheers,
Ferdinand -
Hello @GillesKontrol ,
without further questions or postings, we will consider this topic as solved by Friday, the 11th of august 2023 and flag it accordingly.
Thank you for your understanding,
Maxon SDK Group