2
$\begingroup$

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?

$\endgroup$

1 Answer 1

2
$\begingroup$

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

$\endgroup$
1
  • $\begingroup$ Thanks for the answer! $\endgroup$ Jun 12, 2022 at 19:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .