SOLVED Enabling Team Render in Render Queue

Hi- I have a python script that adds projects to the render queue successfully but now I'd like to be able to enable the Team Render option for them. After reviewing the documentation I felt like BatchRender.SetUseNet(self, n, on) was going to be the answer but I havn't been able to get it to work.

In the main body of the script I set dBatch = c4d.documents.GetBatchRender().
Later in the script I call batchRender definition.

def batchRender(dFilePath, objName):
    dBatchCount = dBatch.GetElementCount() #number of items already in the batch render
    dBatchCount += 1
    dBatch.AddFile(dFilePath +"/" + objName + ".c4d", dBatchCount)
    ####enable Team Render for item

The script doesn't return any errors but the Team Render box is never activated.


Any insight is appreciated.



For now, it look more like a bug. I need to figure out why before creating a bug entry.
I found out that if you add the files first and after in another loop enable them to use teamrender, it works a lot better.

Could you please check if it could fix your issue?

for index, file in enumerate(c4dFiles):
           br.AddFile(file, br.GetElementCount())
       for index in range(0, br.GetElementCount()):        
           br.SetUseNet(index, True)


Thanks Manuel. I was able to work that concept into the overall script.

(Yes, I notice that the thread has been closed, and marked as solved, and I probably shouldn't barge in, but it seems the original script error has never been addressed, so I must mansplain because that's the obnoxious guy I am.)

Two points:

  1. The error in the script above is that the index used in SetUseNet is wrong.
    The indices in the BatchRender element list begin at 0, so the first valid index is 0, and the last is GetElementCount()-1.
    dBatchCount starts as GetElementCount(), which is fine as counter, but as an index, it is the first unused index.
    Then this counter is increased += 1, so now it is the second unused index after the list.
    When AddFile is called with that index, it simply adds the file as last element because it cannot leave empty gaps in the list. It returns True although it didn't use the desired index - it used index-1.
    Now SetUseNet is called with the same index. The reason it fails is that this index is not the index that AddFile actually used. This index is not even valid. There is no element with that index. So, nothing happens.
    If you use dBatchCount-1 as index at this point, or simply never increase dBatchCount in the first place, the script works fine.

  2. The actual API error is that SetUseNet does not raise an IndexError as the docs claim.
    (Other methods like GetElementStatus do.)

Okay, I go annoy someone else now.