Jump to content

Sign in to follow this  
Madara

Change Batch render settings Python

Recommended Posts

Hi everyone. 
I need to change the render settings of the queued scene in the Render Queue. Is there any way to access the dropdown to change render settings before sending the scene to render? I can't find any pieces of information in the python scripting documentation.  What I have now is the script that changes render settings in C4D, saves file, adds the current scene to the render queue, reverts the settings to proof, saves the file again. That's double saving and I would like to avoid it. 
 

import c4d
from c4d import documents, plugins, storage, gui


def GetNextObject(op):
    if op==None: return None
    if op.GetDown(): return op.GetDown()
    while not op.GetNext() and op.GetUp():
        op = op.GetUp()
    return op.GetNext()


def RDFindAndActivate(name): # needs GetNextObject

    myRD = doc.GetFirstRenderData()
    if myRD==None: return
    while myRD:
        if myRD.GetName() == name:
            doc.SetActiveRenderData(myRD)
            c4d.EventAdd
        myRD = GetNextObject(myRD)

    
def Workflow():
    c4d.CallCommand(465003519, 465003519)
    RDFindAndActivate("Print Rendering_0614") 
    c4d.CallCommand(465003525, 465003525) 
    c4d.CallCommand(465003513)
    RDFindAndActivate("Proof Rendering_0614")
    

def main():
    Workflow()
    c4d.EventAdd()
    

if __name__=='__main__':
    main()


 

Share this post


Link to post
Share on other sites

Firstly thing - There is no way to directly access and change the value of the dropdown for the render setting within the Batch Renderer with Python AFAIK.  Which means that while it's not very efficient your approach is not terrible when dealing with a body of files, don't feel bad about it, if it works then that's more important than if it works efficiently.

 

Now onto ways you could improve your code :

 

For a start I don't see anything in your script accessing the batch renderer to get the file.  So that's done first by using the "GetBatchRender" function, e.g. 

 

    batchRender = c4d.documents.GetBatchRender()
    count = batchRender.GetElementCount()
    for i in range(count):
        fileName = batchRender.GetElement(i)

 

This goes through the whole list, but perhaps you only want to deal with the first (top most, just about to render) document, in which case you wouldn't do the for loop but would just do fileName = batchRender.GetElement(0).

 

Next, you can just load in and save the file more directly than using CallCommand using the c4d.document.LoadDocument(file, flags).

 

        myDoc = c4d.documents.LoadDocument(fileName, c4d.SCENEFILTER_PROGRESSALLOWED)
        if myDoc is None:
            return

 

At this point you now have an opened document and can see the progress as the file is loaded in.  Your next step is to switch out the render data in that document.  Just use the code you already have for that, it's fine.  You shouldn't need the EventAdd() function calls in there though.

 

The final step is to re-save your document, this time rather than using CallCommand again you can do it directly.  With c4d.document.SaveDocument(doc, file, flags, format)

 

        result = c4d.documents.SaveDocument(myDoc, fileName, c4d.SAVEDOCUMENTFLAGS_DONTADDTORECENTLIST, c4d.FORMAT_C4DEXPORT)
        if result is False:
            return

 

At this point you should be able to start the batch render and be good to go.  If you want you can do this programmatically again without having to use CallCommand by accessing the BatchRender object's SetRendering() function i.e. batchRender.SetRendering(c4d.BR_START) should do the job.

  • Like 1
  • Namaste 2

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

YOUTUBE CHANNEL:

ABOUT US:

C4D Cafe is the largest CINEMA 4D community. We provide facilities for discussion, showcasing and learning our favorite software :) Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, get your own private messenger, post status updates, manage your profile and much more. If you need to find solution to your problem or otherwise ask for help, Cafe is the right place.
×
×
  • Create New...