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

    Creating a Playblast script falling at the hurdle.

    Cinema 4D SDK
    windows python 2024
    2
    3
    323
    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.
    • A
      AG_Vivimagic
      last edited by

      I am creating a playblast script where it will automate the render settings for the project file and playblast render settings. Code below.

      import c4d
      from c4d import documents, plugins, storage, utils
      
      doc[c4d.DOCUMENT_FPS] = 25 #set file fps
      
      newRenderData = c4d.documents.RenderData()
      newRenderData.SetName('Playblast')
      doc.InsertRenderDataLast(newRenderData)
      doc.SetActiveRenderData(newRenderData) #make it active
      newRenderData.SetBit(8) #make it selected
      
      render_data = documents.GetActiveDocument().GetActiveRenderData()
      c4d.CallCommand(12161) # Render Settings
      newRenderData[c4d.RDATA_RENDERENGINE] = 300001061 #create Viewport Renderer
      c4d.EventAdd()
      newRenderData[c4d.RDATA_XRES] = 1920 #width
      newRenderData[c4d.RDATA_YRES] = 1080 #height
      newRenderData[c4d.RDATA_FRAMERATE] = 25 #set render fps to 25
      newRenderData[c4d.RDATA_FRAMESEQUENCE] = 2 #Frame range to "All Frames"
      newRenderData[c4d.RDATA_FORMAT] = 1125 #MP4 format
      
      
      newRenderData[c4d.RDATA_XRES_VIRTUAL] = 1920 #width
      newRenderData[c4d.RDATA_YRES_VIRTUAL] = 1080 #height
      
      c4d.EventAdd(c4d.EVENT_FORCEREDRAW)
      
      if __name__=='__main__':
          main()
      

      I am getting the render settings to align and execute however it is not updating the UI. It need to look like this !Untitled-1.png image url) Not this Annotation 2025-01-22 094235.jpg

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

        Hello @AG_Vivimagic,

        Welcome to the Maxon developers forum and its community, it is great to have you with us!

        Getting Started

        Before creating your next postings, we would recommend making yourself accustomed with our forum and support procedures. You did not do anything wrong, we point all new users to these rules.

        • Forum Overview: Provides a broad overview of the fundamental structure and rules of this forum, such as the purpose of the different sub-forums or the fact that we will ban users who engage in hate speech or harassment.
        • Support Procedures: Provides a more in detail overview of how we provide technical support for APIs here. This topic will tell you how to ask good questions and limits of our technical support.
        • Forum Features: Provides an overview of the technical features of this forum, such as Markdown markup or file uploads.

        It is strongly recommended to read the first two topics carefully, especially the section Support Procedures: Asking Questions.

        About your First Question

        First of all, your script strikes me as sourced from or at least written with the help of a chat bot. Please disclose when you use AI, otherwise we might refuse to help you. Please also have a look at Support Procedures: Asking Questions, 'I am getting the render settings to align and execute however it is not updating the UI. It need to look like this !' is not a proper question.

        I am assuming that you want to have similar setup of video post effects in your render data, as if when you choose the Preview Hardware Renderer manually. To achieve that, you must manually curate the effects. You should also avoid using raw integer values when setting parameters, as this leads to confusing code and easily to errors. newRenderData.SetBit(8) #make it selected does for example not do what you think it does. The value 8 is BIT_ENABLEPAINT, but you probably mean here BIT_ACTIVE (2).

        Cheers,
        Ferdinand

        Result

        a0644cb2-627b-4f81-8205-799dcd76cd1c-image.png

        Code

        import c4d
        
        doc: c4d.documents.BaseDocument  # The currently active document.
        op: c4d.BaseObject | None  # The primary selected object in `doc`. Can be `None`.
        
        def main() -> None:
            """Called by Cinema 4D when the script is being executed.
            """
            # Set the document FPS.
            doc[c4d.DOCUMENT_FPS] = 25
        
            # Create a new render data instance with the values you wanted.
            rdata: c4d.documents.RenderData = c4d.documents.RenderData()
            rdata.SetName("Playblast")
            rdata[c4d.RDATA_RENDERENGINE] = c4d.RDATA_RENDERENGINE_PREVIEWHARDWARE
            rdata[c4d.RDATA_XRES_VIRTUAL] = 1920
            rdata[c4d.RDATA_YRES_VIRTUAL] = 1080
            rdata[c4d.RDATA_FRAMERATE] = 25 
            rdata[c4d.RDATA_FRAMESEQUENCE] = c4d.RDATA_FRAMESEQUENCE_ALLFRAMES
            rdata[c4d.RDATA_FORMAT] = c4d.FILTER_MOVIE
        
            # We must now curate the video post effects for this render data. This is probably a bit overkill,
            # we could also just delete all of them, since we know that the Preview Renderer only uses MBL which 
            # cannot be removed. But there could be a third party effect which supports the preview renderer 
            # and which is present by default, so we do it the proper way by checking each effect for being
            # compatible with the selected render engine.
            effect: c4d.documents.BaseVideoPost = rdata.GetFirstVideoPost()
            while effect:
                nxt: c4d.documents.BaseVideoPost = effect.GetNext()
                if not effect.RenderEngineCheck(c4d.RDATA_RENDERENGINE_PREVIEWHARDWARE):
                    effect.Remove()
                effect = nxt
        
            # Add the native RDATA_RENDERENGINE_PREVIEWHARDWARE effect.
            previewEffect: c4d.documents.BaseVideoPost = c4d.documents.BaseVideoPost(
                c4d.RDATA_RENDERENGINE_PREVIEWHARDWARE)
            rdata.InsertVideoPostLast(previewEffect)
        
            # Insert the render data and do the other things you wanted to do.
            doc.InsertRenderDataLast(rdata)
            doc.SetActiveRenderData(rdata)
            rdata.SetBit(c4d.BIT_ACTIVE)
            c4d.CallCommand(12161)
        
        if __name__ == '__main__':
            main()
        

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 1
        • A
          AG_Vivimagic
          last edited by

          That is perfect, thank you for being through and concise, lifesaver.

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