Python Script to Export multiple GLTF files (glTF Exporter Unexpected Error)


I want to change the value of a parameter and then export a .gltf file in C4D R23, and do this over and over again for many values. I’m trying to do it with this code, but it is not working:

import c4d
from c4d import documents, plugins
import c4d.documents as docs

def main():
    for ii in range(882):
        obj = doc.SearchObject("Selector")
        obj[c4d.ID_USERDATA,1] = ii
        docs.SaveDocument(c4d.documents.GetActiveDocument(), f'out{ii}.gltf', c4d.SAVEDOCUMENTFLAGS_DONTADDTORECENTLIST, format=c4d.FORMAT_GLTFEXPORT)

if __name__=='__main__':

Unfortunately, I get this error:


How do I fix this? I think I need to specify the gltf export settings somehow, but I don’t know how to do this.


You might have better luck asking here:

Also, maybe post a simple example file showing off the process and the error you’re getting.