fix for error in select hierarchy if no children exist.
This commit is contained in:
@@ -113,44 +113,46 @@ class SelectHierarchy(bpy.types.Operator):
|
|||||||
return context.object
|
return context.object
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
objs = context.selected_objects
|
select_new = []
|
||||||
|
act_new = None
|
||||||
|
|
||||||
|
|
||||||
|
selected_objects = context.selected_objects
|
||||||
obj_act = context.object
|
obj_act = context.object
|
||||||
|
|
||||||
if context.object not in objs:
|
if context.object not in selected_objects:
|
||||||
objs.append(context.object)
|
selected_objects.append(context.object)
|
||||||
|
|
||||||
if not self.properties.extend:
|
|
||||||
# for obj in objs:
|
|
||||||
# obj.select = False
|
|
||||||
bpy.ops.object.select_all(action='DESELECT')
|
|
||||||
|
|
||||||
if self.properties.direction == 'PARENT':
|
if self.properties.direction == 'PARENT':
|
||||||
parents = []
|
for obj in selected_objects:
|
||||||
for obj in objs:
|
|
||||||
parent = obj.parent
|
parent = obj.parent
|
||||||
|
|
||||||
if parent:
|
if parent:
|
||||||
parents.append(parent)
|
|
||||||
|
|
||||||
if obj_act == obj:
|
if obj_act == obj:
|
||||||
context.scene.objects.active = parent
|
act_new = parent
|
||||||
|
|
||||||
parent.select = True
|
select_new.append(parent)
|
||||||
|
|
||||||
if parents:
|
|
||||||
return {'CANCELLED'}
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
children = []
|
for obj in selected_objects:
|
||||||
for obj in objs:
|
select_new.extend(obj.children)
|
||||||
children += list(obj.children)
|
|
||||||
for obj_iter in children:
|
|
||||||
obj_iter.select = True
|
|
||||||
|
|
||||||
children.sort(key=lambda obj_iter: obj_iter.name)
|
if select_new:
|
||||||
context.scene.objects.active = children[0]
|
select_new.sort(key=lambda obj_iter: obj_iter.name)
|
||||||
|
act_new = select_new[0]
|
||||||
|
|
||||||
return {'FINISHED'}
|
# dont edit any object settings above this
|
||||||
|
if select_new:
|
||||||
|
if not self.properties.extend:
|
||||||
|
bpy.ops.object.select_all(action='DESELECT')
|
||||||
|
|
||||||
|
for obj in select_new:
|
||||||
|
obj.select = True
|
||||||
|
|
||||||
|
context.scene.objects.active = act_new
|
||||||
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
return {'CANCELLED'}
|
||||||
|
|
||||||
|
|
||||||
class SubdivisionSet(bpy.types.Operator):
|
class SubdivisionSet(bpy.types.Operator):
|
||||||
|
|||||||
Reference in New Issue
Block a user