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

    Merge scene from user library

    Scheduled Pinned Locked Moved PYTHON Development
    7 Posts 0 Posters 566 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 14/11/2016 at 06:27, xxxxxxxx wrote:

      I have defined my own library (content browser) and added some scenes to it.
      Now I am trying to merge these scenes using following code:

      import c4d, os
      from c4d import gui
      #Welcome to the world of Python
        
      def main() :
        
          userLib = c4d.storage.GeGetStartupWritePath()
          fn = os.path.join(userLib, "library", "browser", "own stuff.lib4d", "spheres test scenes.c4d")
          print "fn: ", fn
          print c4d.documents.MergeDocument(doc,fn, 0)
          c4d.EventAdd()
          print "Done."
        
      if __name__=='__main__':
          main()
      

      The filename given for the merge seems correct:
      fn:  C:\Users\Pim\AppData\Roaming\MAXON\CINEMA 4D R17_8DE13DAD\library\browser\own stuff.lib4d\spheres test scenes.c4d

      The MergeDocument always return false, what am I doing wrong?

      -Pim

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

        On 14/11/2016 at 09:28, xxxxxxxx wrote:

        The .lib4d is a file obviously, so the path you create is not valid for the filesystem. For library content,
        Cinema uses a URL with the preset:// scheme. I may be mistaken, the path you want to use is likely
        something similar to

        preset://own stuff/spheres test scenes.c4d

        Of course this can only be handled and be interpreted correctly by C4D SDK functions/classes.

        Cheers,
        -Niklas

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

          On 15/11/2016 at 00:46, xxxxxxxx wrote:

          Sorry still not working.
          Here my code and console output:

          import c4d, os
          from c4d import gui
          #Welcome to the world of Python
            
          def main() :
              
              userLib = c4d.storage.GeGetStartupWritePath()
              #fn = os.path.join(userLib, "library", "browser", "own stuff.lib4d", "spheres test scenes.c4d")
              fn = "preset://own stuff/spheres test scenes.c4d"
              print "fn: ", fn
              print c4d.documents.MergeDocument(doc,fn, 0)
              c4d.EventAdd()
              print "Done."
            
          if __name__=='__main__':
              main()
            
          #Console output:
          fn:  preset://own stuff/spheres test scenes.c4d/
          False
          Done.
            
          
          

          I also copied the lib4d file to the main c4d library folder: C:\Program Files\MAXON\CINEMA 4D R17\library\browser, but that did not help.

          What do you mean with "Of course this can only be handled and be interpreted correctly by C4D SDK functions/classes.". Can I not merge documents using c4d.documents.MergeDocument(doc,fn, 0)?

          -Pim

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

            On 15/11/2016 at 03:08, xxxxxxxx wrote:

            Hi Pim,

            basically Niklas was already right. I think, the only thing you are missing is to correctly address the preset library correctly.
            For example it looks like so, if you want to load something from the Prime library:

            fn = "preset://prime.lib4d/Example Scenes/Ambient Occlusion/Keys.c4d"
            
            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              On 15/11/2016 at 04:48, xxxxxxxx wrote:

              Ok, it is now working, after adding a sub folder in my own user defined content browser.

              fn = "preset://own stuff.lib4d/water 01.c4d"                               NOT working
                  fn = "preset://own stuff.lib4d/testFolder/water 01.c4d"        + subfolder - Working!!!

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

                On 15/11/2016 at 05:28, xxxxxxxx wrote:

                Hi Pim,

                I'm sorry, but I can't reproduce the need for a sub-folder.
                I created my own preset library named "test" and copied a scene "platonic.c4d" into it.

                fn = "preset://test.lib4d/platonic.c4d"
                c4d.documents.LoadFile(fn)
                

                This worked just fine for me.

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

                  On 15/11/2016 at 07:40, xxxxxxxx wrote:

                  Hi Andreas,

                  Yes, you are correct.
                  I do not what changed (perhaps too focused), but your solution is working.
                  No sub folder needed.

                  Thanks, Pim

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