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

    How to find out if document is rendering from a python tag

    Cinema 4D SDK
    s26 python sdk windows
    2
    3
    590
    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.
    • H
      HerrMay
      last edited by

      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 return True 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

      1 Reply Last reply Reply Quote 0
      • M
        m_adam
        last edited by m_adam

        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_RENDERNOTIFICATION

        Find 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.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        1 Reply Last reply Reply Quote 0
        • H
          HerrMay
          last edited by

          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

          1 Reply Last reply Reply Quote 0
          • H HerrMay referenced this topic on
          • First post
            Last post