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

    Cloner objects missing in Commandline FBX export

    Cinema 4D SDK
    python
    2
    7
    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.
    • J
      janbiko
      last edited by janbiko

      When I'm exporting a c4d file from the Cinem4D GUI as FBX, I get the correct output. But if I load the file in the Commandline and then export it as fbx, all of the cloner objects are missing. Has anybody a solution to this?

      This is how i load the file:

      load = documents.LoadFile(src)
      if not load:
          return False
      
      doc = documents.GetActiveDocument()
      

      and this is how i export:

      FBX_EXPORTER_ID = 1026370 
      documents.SaveDocument(self.doc, self.dst, c4d.SAVEDOCUMENTFLAGS_DONTADDTORECENTLIST, FBX_EXPORTER_ID)
      
      1 Reply Last reply Reply Quote 0
      • ManuelM
        Manuel
        last edited by Manuel

        hello,

        I would like to ask if it's possible to share a bit more of your code.
        Just in what you are showing us, you are using as document, load, doc and self.doc
        Did you have a look at this thread ?

        we are not sure from where you are retrieving the scene in fact.

        i also mark your thread as a question as explain in this thread

        • Q&A New Functionality.

        Cheers,
        Manuel

        MAXON SDK Specialist

        MAXON Registered Developer

        1 Reply Last reply Reply Quote 0
        • J
          janbiko
          last edited by

          Hi Manuel,

          Thanks for your response. I'm loading the scene directly from a .c4d file as follows (with src being the path to the c4d file):

          load = documents.LoadFile(src)
          if not load:
          	return False
          
          self.doc = documents.GetActiveDocument()
          	if self.doc is None:
          		return False
          

          Up to this point, everything works as expected. If I print a list of all objects, the Cloner object is there. However, when I export the scene as an FBX, the Cloner object is missing. I had a look at the thread you linked and experimented with the different export flags, but it didn't seem to have any effect regarding the Cloner issue. Here's the full code for my export method:

          FBX_EXPORTER_ID = 1026370 
          
          def Export(self):
          
              objs = GetAllObjects(self.doc.GetFirstObject(), [])
              for obj in objs:
                  print obj.GetName(), "-", obj.GetType() # the cloner is still here at this point
          
              plug = c4d.plugins.FindPlugin(FBX_EXPORTER_ID, c4d.PLUGINTYPE_SCENESAVER)
              if plug is None:
                  return
          
              # Get a path to save the exported file
              filePath = self.dst
              if filePath is None:
                  return
          
              op = {}
              if plug.Message(c4d.MSG_RETRIEVEPRIVATEDATA, op):
                  print op
                  if "imexporter" not in op:
                      return
          
                  # BaseList2D object stored in "imexporter" key hold the settings
                  fbxExport = op["imexporter"]
                  if fbxExport is None:
                      return
          
                  # set export flags
                  fbxExport[c4d.FBXEXPORT_CLONE_OBJECTS] = True
                  fbxExport[c4d.FBXEXPORT_LIGHTS] = True
                  fbxExport[c4d.FBXEXPORT_SPLINES] = True
                  fbxExport[c4d.FBXEXPORT_LIGHTS] = True
                  fbxExport[c4d.FBXEXPORT_TRACKS] = True
                  fbxExport[c4d.FBXEXPORT_TRIANGULATE] = True
                  fbxExport[c4d.FBXEXPORT_INSTANCES] = True
                  fbxExport[c4d.FBXEXPORT_SUBSTANCES] = True
                  fbxExport[c4d.FBXEXPORT_SAVE_NORMALS] = True
                  fbxExport[c4d.FBXEXPORT_EMBED_TEXTURES] = True
                  fbxExport[c4d.FBXEXPORT_TEXTURES] = True
          
                  # export without dialogs
                  return documents.SaveDocument(self.doc, filePath, c4d.SAVEDOCUMENTFLAGS_DONTADDTORECENTLIST, FBX_EXPORTER_ID)
          

          This works fine for other c4d files that do not contain any Cloner objects. I'm on R21 Trial at the moment, by the way.

          1 Reply Last reply Reply Quote 0
          • ManuelM
            Manuel
            last edited by Manuel

            hello,

            you should add this line to be sure you are not exporting only selected element ?

                    fbxExport[c4d.FBXEXPORT_SELECTION_ONLY] = False
            

            I see you are using this in a class (self.) are you using that in a script or somewhere else ?

            Cheers,
            Manuel

            MAXON SDK Specialist

            MAXON Registered Developer

            1 Reply Last reply Reply Quote 0
            • J
              janbiko
              last edited by

              Hi Manuel,

              unfortunately, setting FBXEXPORT_SELECTION_ONLY didn't change anything. I'm trying to run the export as a Plugin for the Command Line, so all of the code is located in a .pyp file in the plugins directory.
              The command I use to start the conversion is as follows:

              Commandline.exe -nogui ExportC4D "src=E:\Users\janbiko\Documents\test.c4d" "format=fbx"
              

              The file contains a PluginMessage method (as described here https://developers.maxon.net/docs/py/2023_2/misc/pluginstructure.html😞

              def PluginMessage(id, data):
              	if id == c4d.C4DPL_COMMANDLINEARGS:
              		if 'ExportC4D' in sys.argv:
                                      # parse arguments and initialize exporter object
              

              The exporter class then loads a .c4d file and exports it as an .fbx as described in my last post. As I already mentioned, this works fine for other C4D files that to not contain Cloner objects, so I'd assume the general structure of my plugin to be correct.

              1 Reply Last reply Reply Quote 0
              • ManuelM
                Manuel
                last edited by

                hi,

                It's working with a simple scene here.I would try to add a ExecutePasses

                 doc.ExecutePasses(None, True, True, True, c4d.BUILDFLAGS_EXPORT)
                

                Sometimes even twice to be sure all cache are updated.

                Does your scene export correctly if you use cinema4D and the UI ?

                cheers
                Manuel

                MAXON SDK Specialist

                MAXON Registered Developer

                1 Reply Last reply Reply Quote 0
                • ManuelM
                  Manuel
                  last edited by

                  hello,

                  this thread will be considered as "solved" tomorrow if you have nothing to add.

                  Cheers,
                  Manuel

                  MAXON SDK Specialist

                  MAXON Registered Developer

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