hi,
you have to save the document to memory and use the result to merge the document.
When you merge, you have to set the flags to what you want to merge, otherwise it will not merge what you want.
On this example i'm merging a document with another selected document.
import c4d
from c4d import gui
# Welcome to the world of Python
# Main function
def main():
obj = doc.GetActiveObject()
if obj is None:
return
# Isolate the active object
isolateDoc = c4d.documents.IsolateObjects(doc, [obj])
# Creates the Memory File Strcuture
mfs = c4d.storage.MemoryFileStruct()
# Sets the mfs to write mode
mfs.SetMemoryWriteMode()
# save the document to mfs
c4d.documents.SaveDocument(isolateDoc, mfs, c4d.SAVEDOCUMENTFLAGS_DONTADDTORECENTLIST, c4d.FORMAT_C4DEXPORT)
# retrieve the data
data = mfs.GetData()
# Set the MFS to read mode
mfs.SetMemoryReadMode(data[0], data[1] )
flags = c4d.SCENEFILTER_OBJECTS | c4d.SCENEFILTER_MATERIALS
# Load Document
selectedFile = c4d.storage.LoadDialog()
if selectedFile is None:
return
newDoc = c4d.documents.LoadDocument(selectedFile, flags)
#Merge the isolated document with the current one.
c4d.documents.MergeDocument(newDoc, mfs, flags)
c4d.documents.InsertBaseDocument(newDoc)
c4d.documents.SetActiveDocument(newDoc)
# Execute main()
if __name__=='__main__':
main()
Cheers,
Manuel