As I understand it, you need to copy the layers separately and then restore the connections by using an AliasTrans object.
Here's some code in Python, is faster to prototype, sorry:
import c4d
from c4d import gui
def main():
if op == None: return
activeDoc = c4d.documents.GetActiveDocument() # source
firstDoc = c4d.documents.GetFirstDocument() # target
# user must make sure that the first doc is really the target
# and the second doc active!
trans = c4d.AliasTrans()
if not trans or not trans.Init(doc):
return
firstDoc.StartUndo()
op2 = op.GetClone(c4d.COPYFLAGS_RECURSIONCHECK, trans)
op2[c4d.ID_BASELIST_NAME] = "This is a clone!"
firstDoc.InsertObject(op2)
layer = op.GetLayerObject(activeDoc)
layercopy = layer != None
if layercopy:
layer2 = layer.GetClone(c4d.COPYFLAGS_RECURSIONCHECK, trans)
if layer2 == None:
print "Layer copy failed"
layercopy = False
else:
layerHead = firstDoc.GetLayerObjectRoot() # should return GeListHead
# but returns BaseList2D
if layerHead == None:
print "Layer head not returned"
layercopy = False
else:
layer2.InsertUnder(layerHead)
# layerHead.InsertFirst(layer2)
else:
print "No layer to copy"
trans.Translate(True)
firstDoc.AddUndo(c4d.UNDOTYPE_NEW, op2)
if layercopy:
firstDoc.AddUndo(c4d.UNDOTYPE_NEW, layer2)
firstDoc.EndUndo()
c4d.EventAdd()
if __name__=='__main__':
main()
AliasTrans is used in all clone operations, and then after inserting the elements into the new document, called with Translate to resolve all links that got broken during the separate clonings.
Haven't tested whether this works for nested layers; the code obviously only copies the layer of the selected object; you may need to traverse the hierarchy to find all used layers and clone them.