2

I know that this can be done in a few other ways too, but I want to know if it can be done from the right-click select menu

As the title suggests, I want to know if there's a shortcut to selecting a hierarchy from the 3D Viewport itself. For example, I have a few objects parented to an object I want them to follow. Now, I want to duplicate or copy all the objects parented to the parent object including the parent object itself. It's rather tedious to go to the outliner and then do the stuff, so is it possible to just select them from just right-clicking on the parent object in the 3D Viewport? I mean we can just do it by pressing Shift + G or from the search menu or whatever, but is it possible in some way to add it to the right-click menu in Blender?

Timaroberts
  • 12,395
  • 6
  • 39
  • 73
Yousuf Chaudhry
  • 2,783
  • 2
  • 12
  • 38

1 Answers1

2

Select children from parent

enter image description here

bl_info = {
    "name": "My Addon",
    "author": "X Y",
    "version": (0, 1),
    "blender": (2, 80, 0),
    "location": "View3D",
    "description": "select and select children",
    "category": "Object",
}

import bpy from bpy.types import Menu

class MY_OP(bpy.types.Operator): bl_idname = "view3d.select_and_grouped" bl_label = "Operator select and grouped"

def execute(self, context):
    bpy.ops.view3d.select('INVOKE_DEFAULT')
    bpy.ops.object.select_grouped(extend = True)
    return {'FINISHED'}


def menu_func(self, context): self.layout.operator("view3d.select_and_grouped", text="Select Child")

def register(): bpy.utils.register_class(MY_OP) bpy.types.VIEW3D_MT_object_context_menu.append(menu_func)

def unregister(): bpy.utils.unregister_class(MY_OP) bpy.types.VIEW3D_MT_object_context_menu.remove(menu_func)

if name == "main": register()

Reference: How to duplicate parented objects as one object

X Y
  • 5,234
  • 1
  • 6
  • 20