Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Listening to the status of the Pictureviewer (like when Rendering Multiple Takes to Pictureviewer)

    Cinema 4D SDK
    python project tool
    3
    5
    793
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • G
      GillesKontrol
      last edited by

      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!

      ferdinandF 1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand @GillesKontrol
        last edited by

        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:

        1. 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".
        2. 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

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 0
        • G
          GillesKontrol
          last edited by

          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,

          ferdinandF 1 Reply Last reply Reply Quote 0
          • ferdinandF
            ferdinand @GillesKontrol
            last edited by ferdinand

            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 implement NodeData::Message or one of the scripting objects as for example the Python Generator object or the Python tag which implement a message method (which is just a thin wrapper arround NodeData::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 actual TagData::Excute method or the main 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

            MAXON SDK Specialist
            developers.maxon.net

            J 1 Reply Last reply Reply Quote 0
            • J
              jana @ferdinand
              last edited by

              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

              1 Reply Last reply Reply Quote 0
              • First post
                Last post