Outliner - Shift-D to Duplicate

By default you cannot duplicate an object in the Outliner, but you have to Use Copy-Paste.

By adding duplicate.object to the outliner functionality you have a more direct way of duplicating objects across Blender.

20210804_OutlinerDuplicate

It would be great to make this a default keymap in Blender.

3 Likes
1 Like

I use this in combination with Machin3 tools groups and it works great! So it automatically Duplicates the group including the children.

20210804_GroupsDuplicate

I would love to have the option to duplicate with children by default

just replace in my script

Summary
class OUTLINER_OT_duplicate_hierarchy(Operator):    
    bl_idname = "outliner.duplicate_hierarchy"
    bl_label = "Duplicate Hierarchy"
    bl_description = '''Duplicate selected objects with respecting the hierarchy'''
    bl_options = { 'REGISTER', 'UNDO' }

    def execute(self, context):   
        bpy.ops.object.mode_set(mode = 'OBJECT')

        selection_names = [obj.name for obj in bpy.context.selected_objects]

        for o in selection_names:
            obj = bpy.context.scene.objects.get(o)
            bpy.context.view_layer.objects.active = obj
            obj.select_set(True)
            bpy.ops.object.select_grouped(extend=True, type='CHILDREN_RECURSIVE')

        bpy.ops.object.duplicate()
        
        return { 'FINISHED' } 

obj.select_set(True) to obj.select_set(False)
and it will duplicate only children.
You can just copy this code for your own script somewhere.
Or just copy this modified variant:

Summary
class OUTLINER_OT_duplicate_children(Operator):    
    bl_idname = "outliner.duplicate_children"
    bl_label = "Duplicate Children"
    bl_description = '''Duplicate only children objects in selected objects'''
    bl_options = { 'REGISTER', 'UNDO' }

    def execute(self, context):   
        bpy.ops.object.mode_set(mode = 'OBJECT')

        selection_names = [obj.name for obj in bpy.context.selected_objects]

        for o in selection_names:
            obj = bpy.context.scene.objects.get(o)
            bpy.context.view_layer.objects.active = obj
            obj.select_set(False)
            bpy.ops.object.select_grouped(extend=True, type='CHILDREN_RECURSIVE')

        bpy.ops.object.duplicate()
        
        return { 'FINISHED' } 

Also variant with checkbox, but need to run from 3d view if you want “Adjust last operation” panel appeared. Need manually add keymap outliner.duplicate_hierarchy to “3D View - 3D View (Global)”
DH

class OUTLINER_OT_duplicate_hierarchy(Operator):    
    bl_idname = "outliner.duplicate_hierarchy"
    bl_label = "Duplicate Hierarchy"
    bl_description = '''Duplicate selected objects with hierarchy'''
    bl_options = { 'REGISTER', 'UNDO' }

    children_only: bpy.props.BoolProperty (name="Children Only", default = False, description="Duplicate only children objects")

    def execute(self, context):   
        bpy.ops.object.mode_set(mode = 'OBJECT')

        selection_names = [obj.name for obj in bpy.context.selected_objects]

        for o in selection_names:
            obj = bpy.context.scene.objects.get(o)
            bpy.context.view_layer.objects.active = obj
            if self.children_only == True:
                obj.select_set(False)
            if self.children_only == False:
                obj.select_set(True)
            bpy.ops.object.select_grouped(extend=True, type='CHILDREN_RECURSIVE')

        bpy.ops.object.duplicate()
        
        return { 'FINISHED' } 
1 Like

Very cool stuff, I installed your addon and tested it out. Working with Machin3 tool “Groups” though already gives me the functionality to automatically select the whole hierarchy by default.

In my opinion selecting the top node of a hierarchy and hitting either delete or duplicate should duplicate or delete the whole hierarchy by default. But that might be my Maya background

While shift + d is a nice hack :wink:, Blender’s outliner still needs the standard way of duplicate things, which is by pressing a modifier key (usually ctrl or shift) + clicking and dragging the item…

Even in the viewport we should be able to do that too… :wink:

2 Likes

Or maybe you just use some operating system, where deleting folder deletes everything in it?
It seems, Maya just cloned such a behaviour.

1 Like