示例#1
0
        def __del__(self):
            """Revert altered initial selection and layers visibilites
            """

            # saftey check if it's not deleting last instance
            if hasattr(self, "altered_objs"):
                i = 0
                for obj_name in self.altered_objs:
                    bpy.data.objects[obj_name].hide = self.altered_objs_visibilities[i]
                    i += 1
                    bpy.data.objects[obj_name].select = False

                for obj_name in self.not_root_objs:
                    bpy.data.objects[obj_name].select = True

                if self.last_active_obj is not None:
                    # call selection twice to actually change active object
                    self.last_active_obj.select = not self.last_active_obj.select
                    self.last_active_obj.select = not self.last_active_obj.select

                _view3d_utils.switch_layers_visibility(self.layers_visibilities, False)
示例#2
0
        def __del__(self):
            """Revert altered initial selection and layers visibilites
            """

            # saftey check if it's not deleting last instance
            if hasattr(self, "altered_objs"):
                i = 0
                for obj_name in self.altered_objs:
                    bpy.data.objects[obj_name].hide = self.altered_objs_visibilities[i]
                    i += 1
                    bpy.data.objects[obj_name].select = False

                for obj_name in self.not_root_objs:
                    bpy.data.objects[obj_name].select = True

                if self.last_active_obj is not None:
                    # call selection twice to actually change active object
                    self.last_active_obj.select = not self.last_active_obj.select
                    self.last_active_obj.select = not self.last_active_obj.select

                _view3d_utils.switch_layers_visibility(self.layers_visibilities, False)
示例#3
0
        def __init__(self):
            """Shows all layer to be able to alter selection on the whole scene and
            alter Blender selection the way that:
            1. if only child within root is selected -> selects root too
            2. if only root is selected -> select all children
            3. if root and some children are selected -> don't change selection
            """
            self.layers_visibilities = _view3d_utils.switch_layers_visibility(
                [], True)
            self.last_active_obj = bpy.context.active_object
            self.altered_objs = []
            self.altered_objs_visibilities = []
            self.not_root_objs = []

            for obj in bpy.context.selected_objects:
                root = _object_utils.get_scs_root(obj)
                if root:
                    if root != obj:
                        if not root.select:
                            root.select = True
                            self.altered_objs.append(root.name)
                    else:
                        children = _object_utils.get_children(obj)
                        local_reselected_objs = []
                        for child_obj in children:
                            local_reselected_objs.append(child_obj.name)
                            # if some child is selected this means we won't reselect nothing in this game objecdt
                            if child_obj.select:
                                local_reselected_objs = []
                                break
                        self.altered_objs.extend(local_reselected_objs)
                else:
                    obj.select = False
                    self.not_root_objs.append(obj.name)

            for obj_name in self.altered_objs:
                self.altered_objs_visibilities.append(
                    bpy.data.objects[obj_name].hide)
                bpy.data.objects[obj_name].hide = False
                bpy.data.objects[obj_name].select = True
示例#4
0
        def __init__(self):
            """Shows all layer to be able to alter selection on the whole scene and
            alter Blender selection the way that:
            1. if only child within root is selected -> selects root too
            2. if only root is selected -> select all children
            3. if root and some children are selected -> don't change selection
            """
            self.layers_visibilities = _view3d_utils.switch_layers_visibility([], True)
            self.last_active_obj = bpy.context.active_object
            self.altered_objs = []
            self.altered_objs_visibilities = []
            self.not_root_objs = []

            for obj in bpy.context.selected_objects:
                root = _object_utils.get_scs_root(obj)
                if root:
                    if root != obj:
                        if not root.select:
                            root.select = True
                            self.altered_objs.append(root.name)
                    else:
                        children = _object_utils.get_children(obj)
                        local_reselected_objs = []
                        for child_obj in children:
                            local_reselected_objs.append(child_obj.name)
                            # if some child is selected this means we won't reselect nothing in this game objecdt
                            if child_obj.select:
                                local_reselected_objs = []
                                break
                        self.altered_objs.extend(local_reselected_objs)
                else:
                    obj.select = False
                    self.not_root_objs.append(obj.name)

            for obj_name in self.altered_objs:
                self.altered_objs_visibilities.append(bpy.data.objects[obj_name].hide)
                bpy.data.objects[obj_name].hide = False
                bpy.data.objects[obj_name].select = True
示例#5
0
 def __del__(self):
     """Destructor with reverting visible layers.
     """
     _view3d_utils.switch_layers_visibility(self.layers_visibilities,
                                            False)
示例#6
0
 def __init__(self):
     """Constructor used for showing all scene visibility layers.
     This provides possibility to updates world matrixes even on hidden objects.
     """
     self.layers_visibilities = _view3d_utils.switch_layers_visibility(
         [], True)
示例#7
0
 def __del__(self):
     """Destructor with reverting visible layers.
     """
     _view3d_utils.switch_layers_visibility(self.layers_visibilities, False)
示例#8
0
 def __init__(self):
     """Constructor used for showing all scene visibility layers.
     This provides possibility to updates world matrixes even on hidden objects.
     """
     self.layers_visibilities = _view3d_utils.switch_layers_visibility([], True)