Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python 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

    SaveDocument Error, Alembic export

    Scheduled Pinned Locked Moved PYTHON Development
    3 Posts 0 Posters 456 Views
    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.
    • H Offline
      Helper
      last edited by

      On 27/04/2017 at 08:26, xxxxxxxx wrote:

      Hi,

      I am new to c4d API, and I have  a strange error when trying to use SaveDocument command, using alembic plugin. I am wondering if it's an error in C4D or if I do something wrong...

      In a new C4d session/document (R17 or R18), I only create a cube and a cone. (cube is selected, cone is not)

      Following that example:
      https://github.com/PluginCafe/cinema4d_py_sdk/blob/master/scripts/ExportAlembic.py

      I added a 'print', before and after changing the export settings.

      import c4d
      from c4d import gui
      #Welcome to the world of Python
      from c4d import documents, plugins
      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 ="C:/temp/C4dExport_v001.abc"
        
          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
              
              print 'SELECTION BEFORE: ',  abcExport[c4d.ABCEXPORT_SELECTION_ONLY]
              
              # Change Alembic export settings
              abcExport[c4d.ABCEXPORT_SELECTION_ONLY] = True
              abcExport[c4d.ABCEXPORT_PARTICLES] = True
              abcExport[c4d.ABCEXPORT_PARTICLE_GEOMETRY] = True
              
              
              print 'SELECTION AFTER: ',  abcExport[c4d.ABCEXPORT_SELECTION_ONLY]
        
        
              # Finally export the document
              if documents.SaveDocument(doc, filePath, c4d.SAVEDOCUMENTFLAGS_DONTADDTORECENTLIST, 1028082) :
                  print "Document successfully exported to:"
                  print filePath
              else:
                  print "Export failed!"
                  
      if __name__=='__main__':
          main()
      

      The error is:
      1- If I didn't open the actual Alembic plugin UI yet (in my c4d session). It seems I can't update the preferences. IE:  Before = 0, then I set it to True, After = 0...

      The export won't take into consideration the preferences I've tried to set up for abcExport[c4d.ABCEXPORT_SELECTION_ONLY]

      2- If I manually open Alembic exporter UI (File --> Export --> Alembic)... I do not need to change anything, I do not need to export (I can cancell).

      Then, I can execute my script, and the preferences I'll choose for abcExport[c4d.ABCEXPORT_SELECTION_ONLY] will be taken into consideration...

      IE: Before = 0, then I set it to True, After = 1... or Before = 1, then I set it to False, After = 0

      Any idea?

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 28/04/2017 at 03:00, xxxxxxxx wrote:

        Hi,

        welcome to the Plugin Café forums 🙂

        This was actually a known issue (and special for the selection only parameter). But it should have been fixed with version 18.030. I just tried your code here in 18.041 without problem. So I'm a bit confused, that you say, you can reproduce this in R18.

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 28/04/2017 at 08:20, xxxxxxxx wrote:

          Hey thanks Andreas,

          your right. I was using C4D R18.020 and just upgraded to R18.041.

          It seems to work fine!

          😉

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