diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-02-25 18:41:46 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-02-25 18:41:46 +0300 |
commit | 0b33be5a7b033ab3890abe4f3f53a03014aede15 (patch) | |
tree | 5d23f35b1591253dc3933aaced631cddde6982d2 | |
parent | 57baa94631df9a6d0eda29bb28a42ab19d05ab39 (diff) |
select parent/child in object mode with [] keys, like pose mode.
also needed to extend the RNA api to allow C to set enums without meaningful values.
-rw-r--r-- | release/scripts/op/object.py | 43 | ||||
-rw-r--r-- | source/blender/editors/object/object_ops.c | 12 | ||||
-rw-r--r-- | source/blender/makesrna/RNA_access.h | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_access.c | 14 |
4 files changed, 70 insertions, 0 deletions
diff --git a/release/scripts/op/object.py b/release/scripts/op/object.py index 24195b9d152..b9bd3cb6459 100644 --- a/release/scripts/op/object.py +++ b/release/scripts/op/object.py @@ -96,6 +96,48 @@ class SelectCamera(bpy.types.Operator): return {'FINISHED'} +class SelectHierarchy(bpy.types.Operator): + '''Select object relative to the active objects position in the hierarchy''' + bl_idname = "object.select_hierarchy" + bl_label = "Select Hierarchy" + bl_register = True + bl_undo = True + + direction = EnumProperty(items=( + ('PARENT', "Parent", ""), + ('CHILD', "Child", "")), + name="Direction", + description="Direction to select in the hierarchy", + default='PARENT') + + extend = BoolProperty(name="Extend", description="Extend the existing selection", default=False) + + def poll(self, context): + return context.object + + def execute(self, context): + obj = context.object + if self.properties.direction == 'PARENT': + parent = obj.parent + if not parent: + return {'CANCELLED'} + obj_act = parent + else: + children = obj.children + if len(children) != 1: + return {'CANCELLED'} + obj_act = children[0] + + if not self.properties.extend: + # obj.selected = False + bpy.ops.object.select_all(action='DESELECT') + + obj_act.selected = True + context.scene.objects.active = obj_act + + return {'FINISHED'} + + class SubdivisionSet(bpy.types.Operator): '''Sets a Subdivision Surface Level (1-5)''' @@ -471,6 +513,7 @@ class MakeDupliFace(bpy.types.Operator): classes = [ SelectPattern, SelectCamera, + SelectHierarchy, SubdivisionSet, ShapeTransfer, JoinUVs, diff --git a/source/blender/editors/object/object_ops.c b/source/blender/editors/object/object_ops.c index d7ffa1d983b..ab50bd4c37c 100644 --- a/source/blender/editors/object/object_ops.c +++ b/source/blender/editors/object/object_ops.c @@ -289,6 +289,18 @@ void ED_keymap_object(wmKeyConfig *keyconf) WM_keymap_add_item(keymap, "OBJECT_OT_select_grouped", GKEY, KM_PRESS, KM_SHIFT, 0); WM_keymap_add_item(keymap, "OBJECT_OT_select_mirror", MKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0); + kmi= WM_keymap_add_item(keymap, "OBJECT_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, 0, 0); + RNA_enum_set_identifier(kmi->ptr, "direction", "PARENT"); + kmi= WM_keymap_add_item(keymap, "OBJECT_OT_select_hierarchy", LEFTBRACKETKEY, KM_PRESS, KM_SHIFT, 0); + RNA_enum_set_identifier(kmi->ptr, "direction", "PARENT"); + RNA_boolean_set(kmi->ptr, "extend", 1); + + kmi= WM_keymap_add_item(keymap, "OBJECT_OT_select_hierarchy", RIGHTBRACKETKEY, KM_PRESS, 0, 0); + RNA_enum_set_identifier(kmi->ptr, "direction", "CHILD"); + kmi= WM_keymap_add_item(keymap, "OBJECT_OT_select_hierarchy", RIGHTBRACKETKEY, KM_PRESS, KM_SHIFT, 0); + RNA_enum_set_identifier(kmi->ptr, "direction", "CHILD"); + RNA_boolean_set(kmi->ptr, "extend", 1); + WM_keymap_verify_item(keymap, "OBJECT_OT_parent_set", PKEY, KM_PRESS, KM_CTRL, 0); WM_keymap_verify_item(keymap, "OBJECT_OT_parent_no_inverse_set", PKEY, KM_PRESS, KM_CTRL|KM_SHIFT, 0); WM_keymap_verify_item(keymap, "OBJECT_OT_parent_clear", PKEY, KM_PRESS, KM_ALT, 0); diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 2ab74dd2a3e..f55207674fe 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -809,6 +809,7 @@ void RNA_float_set_array(PointerRNA *ptr, const char *name, const float *values) int RNA_enum_get(PointerRNA *ptr, const char *name); void RNA_enum_set(PointerRNA *ptr, const char *name, int value); +void RNA_enum_set_identifier(PointerRNA *ptr, const char *name, const char *id); int RNA_enum_is_equal(struct bContext *C, PointerRNA *ptr, const char *name, const char *enumname); /* lower level functions that donr use a PointerRNA */ diff --git a/source/blender/makesrna/intern/rna_access.c b/source/blender/makesrna/intern/rna_access.c index 9176dcf0334..4a50be6f58b 100644 --- a/source/blender/makesrna/intern/rna_access.c +++ b/source/blender/makesrna/intern/rna_access.c @@ -3295,6 +3295,20 @@ void RNA_enum_set(PointerRNA *ptr, const char *name, int value) printf("RNA_enum_set: %s.%s not found.\n", ptr->type->identifier, name); } +void RNA_enum_set_identifier(PointerRNA *ptr, const char *name, const char *id) +{ + PropertyRNA *prop= RNA_struct_find_property(ptr, name); + + if(prop) { + int value; + if(RNA_property_enum_value(NULL, ptr, prop, id, &value)) + RNA_property_enum_set(ptr, prop, value); + else + printf("RNA_enum_set_identifier: %s.%s has no enum id '%s'.\n", ptr->type->identifier, name, id); + } else + printf("RNA_enum_set_identifier: %s.%s not found.\n", ptr->type->identifier, name); +} + int RNA_enum_is_equal(bContext *C, PointerRNA *ptr, const char *name, const char *enumname) { PropertyRNA *prop= RNA_struct_find_property(ptr, name); |