Python - Cinema 4D R20.057 - Export to Alembic without Dialog



  • Hi all,

    i know the example on github. I tried to export to alembic. But the alembic-file is not written and I don't get any error. If I set the parameter to "c4d.FORMAT_ABCEXPORT" nothing changes. Only when I use "c4d.FORMAT_C4DEXPORT" it writes a file. But thats not what I want. When I use the script on Github and change the "filePath" to an actual path it works only with c4d Export. But not with Alembic.

    I wonder what I do wrong. Heres the code:

    """
    Export Settings Example
    This example shows how to change an exporter settings.
    This works also for importers/scene loaders.
    """
    
    import c4d
    from c4d import documents, plugins, storage
    
    def main():
        # Get Alembic export plugin, 1028082 is its ID
        plug = plugins.FindPlugin(1028082, c4d.PLUGINTYPE_SCENESAVER)
        if plug is None:
            return
        
        # Get a path to save the exported file
        filePath = "D:\\a.abc"
        if filePath is None:
            return
        
        op = {}
        # Send MSG_RETRIEVEPRIVATEDATA to Alembic export plugin
        if plug.Message(c4d.MSG_RETRIEVEPRIVATEDATA, op):
            if "imexporter" not in op:
                return
            
            # BaseList2D object stored in "imexporter" key hold the settings
            abcExport = op["imexporter"]
            if abcExport is None:
                return
            
            # Change Alembic export settings
            abcExport[c4d.ABCEXPORT_SELECTION_ONLY] = True
            abcExport[c4d.ABCEXPORT_PARTICLES] = True
            abcExport[c4d.ABCEXPORT_PARTICLE_GEOMETRY] = True
            
            # Finally export the document
            if documents.SaveDocument(doc, filePath, c4d.SAVEDOCUMENTFLAGS_DONTADDTORECENTLIST, c4d.FORMAT_ABCEXPORT):
                print "Document successfully exported to:"
                print filePath
            else:
                print "Export failed!"
    
    
    if __name__=='__main__':
        main()
    

    Btw: I don't get any error. And if I change the parameter "c4d.FORMAT_ABCEXPORT" back to "1028082" doesnt change anything. And I dont want to get a dialog either.

    It's the same with the simple code below:

    import c4d
    from c4d import documents, plugins, storage
    
    def main():
    
        # Get a path to save the exported file
        filePath = "D:\\hallo.abc"
    
        c4d.documents.SaveDocument(doc, filePath, c4d.SAVEDOCUMENTFLAGS_DONTADDTORECENTLIST, c4d.FORMAT_ABCEXPORT)
        c4d.EventAdd()
            
    
    if __name__=='__main__':
        main()
    

    Thx in advance!



  • Hi @PdZ, are you sure you get the permission(Cinema 4D) to write directly into a drive folder? Could you try on your desktop or any other one that you are sure is writable?

    Cheers,
    Maxime.



  • Dear m_adam,

    thx for your response. Iam pretty sure C4D has permission to write but weirdly enough it only happens with exports other than .c4d.
    Fortunately I was able to use R20 new feature to write alembics out by using the build in function "save as alembic and delete".



  • Hi @PdZ I'm not able to reproduce it, in a folder I do have the right to write, both success, in a folder I do not have the right to write both fails.

    Could you try for a folder where you are sure your user is allowed to write such as a temp folder?

    Cheers,
    Maxime.



  • @PdZ does it's solved?



  • Yes it is! Thank you very much!


Log in to reply