[SOLVED] help to copy objects to others embedded scenes wiouth linking

I need copy objects to new scenes without links…


import bpy

def selectAll():
    bpy.ops.object.select_all(action='SELECT')
    
def deselectAll():
    bpy.ops.object.select_all(action='DESELECT')


def selectOnlyOneObjectByName(obn,scn = bpy.context.scene):
    ob = bpy.context.scene.objects[obn]
    bpy.ops.object.select_all(action='DESELECT')
    scn.objects.active = ob
    ob.select = True


def createNewScene(name, tipo='NEW', retornamos=False, motor='CYCLES'):
    scn_original = bpy.context.scene.name
    if tipo == 'NEW':
        bpy.ops.scene.new(type='NEW')
    if tipo == 'FULL_COPY':
        bpy.ops.scene.new(type='FULL_COPY')
    bpy.context.scene.name = name
    new_scn = bpy.context.scene.name
    if motor == 'CYCLES':
        bpy.context.scene.render.engine = motor
    if retornamos:
        bpy.context.screen.scene = bpy.data.scenes[scn_original]
    return [scn_original,new_scn]


if 'Backup_Original_Scene' not in bpy.data.scenes:
    createNewScene('Backup_Original_Scene','FULL_COPY', True)


createNewScene('test','NEW',True)
for ob in bpy.context.scene.objects:
    if ob.type == 'MESH': 
        deselectAll()
        selectOnlyOneObjectByName(ob.name)
        bpy.ops.object.duplicate(linked=False, mode='TRANSLATION')
        ob.name = ob.name + "_copiado"
        bpy.ops.object.make_links_scene(scene='test')
        selectOnlyOneObjectByName(ob.name)
        bpy.ops.object.delete(use_global=False)


My problem:
in original scene named Scene have one Cube.000 an run script, change to Cube.002 and linked to scene test…
I Need the original scene dont modify anything…

My target:
‘Scene’ have Cube.000
‘Backup_Original_Scene’ have Cube.001 (copy from Scene)
‘test’ have Cube.002 (copy from Scene)

It would be great to make a cp bpy.context.scene.objects[‘Cube.000’] bpy.data.scenes[‘test’]
without link but it is not so easy…

¿It is possible?. Thanks.

Solved:


import bpy

def selectAll():
    bpy.ops.object.select_all(action='SELECT')
    
def deselectAll():
    bpy.ops.object.select_all(action='DESELECT')

def selectOnlyOneObjectByName(obn,scn = bpy.context.scene):
    ob = bpy.context.scene.objects[obn]
    bpy.ops.object.select_all(action='DESELECT')
    scn.objects.active = ob
    ob.select = True

def createNewScene(name, tipo='NEW', retornamos=False, motor='CYCLES'):
    scn_original = bpy.context.scene.name
    if tipo == 'NEW':
        bpy.ops.scene.new(type='NEW')
    if tipo == 'FULL_COPY':
        bpy.ops.scene.new(type='FULL_COPY')
    bpy.context.scene.name = name
    new_scn = bpy.context.scene.name
    if motor == 'CYCLES':
        bpy.context.scene.render.engine = motor
    if retornamos:
        bpy.context.screen.scene = bpy.data.scenes[scn_original]
    return [scn_original,new_scn]

if 'Backup_Original_Scene' not in bpy.data.scenes:
    createNewScene('Backup_Original_Scene','FULL_COPY', True)


createNewScene('test','NEW',True)
for ob in bpy.context.scene.objects:
    if ob.type == 'MESH': 
        deselectAll()
        selectOnlyOneObjectByName(ob.name)
        name_org = ob.name
        bpy.ops.object.duplicate(linked=False, mode='TRANSLATION')
        bpy.context.selected_objects[0].name = bpy.context.selected_objects[0].name + "_copy" 
        bpy.ops.object.make_links_scene(scene='test')
        selectOnlyOneObjectByName(bpy.context.selected_objects[0].name)
        bpy.ops.object.delete(use_global=False)