Merge scene from user library

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

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

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

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"

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!!!

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.

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