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

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

    Cinema 4D SDK
    python r20
    2
    6
    1.5k
    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.
    • P
      PdZ
      last edited by PdZ

      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!

      1 Reply Last reply Reply Quote 0
      • M
        m_adam
        last edited by

        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.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        1 Reply Last reply Reply Quote 0
        • P
          PdZ
          last edited by

          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".

          1 Reply Last reply Reply Quote 0
          • M
            m_adam
            last edited by

            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.

            MAXON SDK Specialist

            Development Blog, MAXON Registered Developer

            1 Reply Last reply Reply Quote 0
            • M
              m_adam
              last edited by

              @PdZ does it's solved?

              MAXON SDK Specialist

              Development Blog, MAXON Registered Developer

              1 Reply Last reply Reply Quote 0
              • P
                PdZ
                last edited by

                Yes it is! Thank you very much!

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