Skip to content

Instantly share code, notes, and snippets.

@p2or
Last active May 21, 2023 18:37
Show Gist options
  • Save p2or/0f0c86e41717523d95445a203ba9f181 to your computer and use it in GitHub Desktop.
Save p2or/0f0c86e41717523d95445a203ba9f181 to your computer and use it in GitHub Desktop.
Custom scene duplication #Blender
bl_info = {
"name": "Duplicate Scene",
"description": "",
"author": "poor",
"version": (0, 0, 1),
"blender": (2, 70, 0),
"location": "3D View > Spacebar > Duplicate Scene",
"category": "3D View"
}
import bpy
def dupeObj(ob, scn):
ob_copy = ob.copy()
ob_data = ob.data.copy()
ob_copy.data = ob_data
scn.objects.link(ob_copy)
scn.objects.active = ob_copy
class CustomDuplicateSceneOperator(bpy.types.Operator):
"""Duplicate all objects in the scene without material duplication"""
bl_idname = "view3d.duplicate_scene"
bl_label = "Duplicate Scene"
bl_options = {'REGISTER', 'UNDO'}
def execute(self, context):
# current scene
orig_scene = context.scene.name
bpy.ops.scene.new(type='NEW')
# get the new scene
new_scene = bpy.context.scene
for ob in bpy.data.scenes[orig_scene].objects:
dupeObj(ob, new_scene)
self.report({'INFO'}, "Scene duplicated to {}".format(new_scene.name))
return {'FINISHED'}
def register():
bpy.utils.register_class(CustomDuplicateSceneOperator)
def unregister():
bpy.utils.unregister_class(CustomDuplicateSceneOperator)
if __name__ == "__main__":
register()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment