hello,
the xref will import the material unless it's on Generator mode.
You can maybe juste merge de target document with your current document. This work with a simple scene of course but can go really more complicated.
def main(): if op is None: raise ValueError("you have to select at least one object") if not op.IsInstanceOf(c4d.Oxref): raise ValueError("selected object must be a xref") # Starts Undo doc.StartUndo() # if the xref is in generator mode, we need to import the material from the target document. if op[c4d.ID_CA_XREF_GENERATOR]: targetDoc = op[c4d.ID_CA_XREF_FILE] c4d.documents.MergeDocument(doc, targetDoc, c4d.SCENEFILTER_MATERIALS | c4d.SCENEFILTER_OBJECTS, None) else: result = c4d.utils.SendModelingCommand(command = c4d.MCOMMAND_CURRENTSTATETOOBJECT, list = [op] , doc=doc) if result: doc.InsertObject(result[0]) doc.AddUndo(c4d.UNDOTYPE_NEW, result[0]) else: raise ValueError("couldn't retrieves the CSTO of the xref") #remove the existing xref doc.AddUndo(c4d.UNDOTYPE_CHANGE, op) op.Remove() doc.EndUndo() c4d.EventAdd()Cheers,
Manuel