示例#1
0
        def execute_export(self, context, disable_local_view):
            """Actually executes export of current selected objects (bpy.context.selected_objects)

            :param context: operator context
            :type context: bpy_struct
            :param disable_local_view: True if you want to disable local view after export
            :type disable_local_view: bool
            :return: succes of batch export
            :rtype: {'FINISHED'} | {'CANCELLED'}
            """
            _get_scs_globals(
            ).content_type = 'selection'  # NOTE: I'm not sure if this is still necessary.

            try:
                result = _export.batch_export(
                    self, tuple(bpy.context.selected_objects))
            except Exception as e:

                result = {"CANCELLED"}
                context.window.cursor_modal_restore()

                import traceback

                traceback.print_exc()
                lprint(
                    "E Unexpected %r accured during batch export, see stack trace above.",
                    (type(e).__name__, ),
                    report_errors=1,
                    report_warnings=1)

            if disable_local_view:
                _view3d_utils.switch_local_view(False)

            return result
示例#2
0
        def execute_export(self, context, disable_local_view):
            """Actually executes export of current selected objects (bpy.context.selected_objects)

            :param context: operator context
            :type context: bpy_struct
            :param disable_local_view: True if you want to disable local view after export
            :type disable_local_view: bool
            :return: succes of batch export
            :rtype: {'FINISHED'} | {'CANCELLED'}
            """
            _get_scs_globals().content_type = 'selection'  # NOTE: I'm not sure if this is still necessary.

            try:
                result = _export.batch_export(self, tuple(bpy.context.selected_objects), exclude_switched_off=False)
            except Exception as e:

                result = {"CANCELLED"}
                context.window.cursor_modal_restore()

                import traceback

                traceback.print_exc()
                lprint("E Unexpected %r accured during batch export, see stack trace above.",
                       (type(e).__name__,),
                       report_errors=1,
                       report_warnings=1)

            if disable_local_view:
                _view3d_utils.switch_local_view(False)

            return result
示例#3
0
    def execute(self, context):
        lprint('D Export From Menu...')

        from io_scs_tools import exp as _export
        from io_scs_tools.utils import object as _object_utils

        filepath = os.path.dirname(self.filepath)

        # convert it to None, so export will ignore given menu file path and try to export to other none menu set paths
        if self.filepath == "":
            filepath = None

        export_scope = _get_scs_globals().export_scope
        init_obj_list = {}
        if export_scope == "selection":
            for obj in bpy.context.selected_objects:
                root = _object_utils.get_scs_root(obj)
                if root:
                    if root != obj:  # add only selected children
                        init_obj_list[obj.name] = obj
                        init_obj_list[root.name] = root
                    else:  # add every children if all are unselected
                        children = _object_utils.get_children(obj)
                        local_reselected_objs = []
                        for child_obj in children:
                            local_reselected_objs.append(child_obj)
                            # if some child is selected this means we won't reselect nothing in this game object
                            if child_obj.select:
                                local_reselected_objs = []
                                break

                        for reselected_obj in local_reselected_objs:
                            init_obj_list[reselected_obj.name] = reselected_obj

            init_obj_list = tuple(init_obj_list.values())
        elif export_scope == "scene":
            init_obj_list = tuple(bpy.context.scene.objects)
        elif export_scope == 'scenes':
            init_obj_list = tuple(bpy.data.objects)

        # check extension for EF format and properly assign it to name suffix
        ef_name_suffix = ""
        if _get_scs_globals().export_output_type == "EF":
            ef_name_suffix = ".ef"

        try:
            result = _export.batch_export(self, init_obj_list, name_suffix=ef_name_suffix, menu_filepath=filepath)
        except Exception as e:

            result = {"CANCELLED"}
            context.window.cursor_modal_restore()

            trace_str = traceback.format_exc().replace("\n", "\n\t   ")
            lprint("E Unexpected %r accured during batch export:\n\t   %s",
                   (type(e).__name__, trace_str),
                   report_errors=1,
                   report_warnings=1)

        return result
示例#4
0
    def execute(self, context):
        lprint('D Export From Menu...')

        from io_scs_tools import exp as _export
        from io_scs_tools.utils import object as _object_utils

        filepath = os.path.dirname(self.filepath)

        # convert it to None, so export will ignore given menu file path and try to export to other none menu set paths
        if self.filepath == "":
            filepath = None

        export_scope = _get_scs_globals().export_scope
        init_obj_list = {}
        if export_scope == "selection":
            for obj in bpy.context.selected_objects:
                root = _object_utils.get_scs_root(obj)
                if root:
                    if root != obj:  # add only selected children
                        init_obj_list[obj.name] = obj
                        init_obj_list[root.name] = root
                    else:  # add every children if all are unselected
                        children = _object_utils.get_children(obj)
                        local_reselected_objs = []
                        for child_obj in children:
                            local_reselected_objs.append(child_obj)
                            # if some child is selected this means we won't reselect nothing in this game object
                            if child_obj.select:
                                local_reselected_objs = []
                                break

                        for reselected_obj in local_reselected_objs:
                            init_obj_list[reselected_obj.name] = reselected_obj

            init_obj_list = tuple(init_obj_list.values())
        elif export_scope == "scene":
            init_obj_list = tuple(bpy.context.scene.objects)
        elif export_scope == 'scenes':
            init_obj_list = tuple(bpy.data.objects)

        try:
            result = _export.batch_export(self, init_obj_list, menu_filepath=filepath)
        except Exception as e:

            result = {"CANCELLED"}
            context.window.cursor_modal_restore()

            import traceback

            traceback.print_exc()
            lprint("E Unexpected %r accured during batch export, see stack trace above.",
                   (type(e).__name__,),
                   report_errors=1,
                   report_warnings=1)

        return result
示例#5
0
    def execute(self, context):
        lprint('D Export From Menu...')

        from io_scs_tools import exp as _export
        from io_scs_tools.utils import object as _object_utils

        filepath = os.path.dirname(self.filepath)

        export_type = _get_scs_globals().content_type
        init_obj_list = {}
        if export_type == "selection":
            for obj in bpy.context.selected_objects:
                root = _object_utils.get_scs_root(obj)
                if root:
                    if root != obj:  # add only selected children
                        init_obj_list[obj.name] = obj
                        init_obj_list[root.name] = root
                    else:  # add every children if all are unselected
                        children = _object_utils.get_children(obj)
                        local_reselected_objs = []
                        for child_obj in children:
                            local_reselected_objs.append(child_obj)
                            # if some child is selected this means we won't reselect nothing in this game object
                            if child_obj.select:
                                local_reselected_objs = []
                                break

                        for reselected_obj in local_reselected_objs:
                            init_obj_list[reselected_obj.name] = reselected_obj

            init_obj_list = tuple(init_obj_list.values())
        elif export_type == "scene":
            init_obj_list = tuple(bpy.context.scene.objects)
        elif export_type == 'scenes':
            init_obj_list = tuple(bpy.data.objects)

        try:
            result = _export.batch_export(self, init_obj_list,
                                          export_type != "selection", filepath)
        except Exception as e:

            result = {"CANCELLED"}
            context.window.cursor_modal_restore()

            import traceback

            traceback.print_exc()
            lprint(
                "E Unexpected %r accured during batch export, see stack trace above.",
                (type(e).__name__, ),
                report_errors=1,
                report_warnings=1)

        return result
示例#6
0
    def execute_export(self, context, without_preview, menu_filepath=None):
        """Executes export.

        :param context: operator context
        :type context: bpy_struct
        :param without_preview: is export run without preview?
        :type without_preview: bool
        :param menu_filepath: filepath used from menu export, if not provided export is done to none menu set path
        :type menu_filepath: str
        :return: success of batch export
        :rtype: {'FINISHED'} | {'CANCELLED'}
        """

        # show all collections, if normal export, so all modifiers will be applied correctly
        if without_preview:
            self.init()

        init_obj_list = self.get_objects_for_export()

        # check extension for EF format and properly assign it to name suffix
        ef_name_suffix = ""
        if _get_scs_globals().export_output_type == "EF":
            ef_name_suffix = ".ef"

        try:
            result = _export.batch_export(self,
                                          init_obj_list,
                                          name_suffix=ef_name_suffix,
                                          menu_filepath=menu_filepath)
        except Exception as e:

            result = {"CANCELLED"}
            context.window.cursor_modal_restore()

            import traceback

            trace_str = traceback.format_exc().replace("\n", "\n\t   ")
            lprint("E Unexpected %r accured during batch export:\n\t   %s",
                   (type(e).__name__, trace_str),
                   report_errors=1,
                   report_warnings=1)

        # restore collections visiblities if normal export
        if without_preview:
            self.finish()

        return result
示例#7
0
        def execute(self, context):
            lprint('D Export All...')
            _get_scs_globals().content_type = 'scenes'
            init_obj_list = tuple(bpy.data.objects)  # Get all objects from all Scenes

            try:
                result = _export.batch_export(self, init_obj_list)
            except Exception as e:

                result = {"CANCELLED"}
                context.window.cursor_modal_restore()

                import traceback

                traceback.print_exc()
                lprint("E Unexpected %r accured during batch export, see stack trace above.",
                       (type(e).__name__,),
                       report_errors=1,
                       report_warnings=1)

            return result
示例#8
0
        def execute(self, context):
            lprint('D Export All...')
            _get_scs_globals().content_type = 'scenes'
            init_obj_list = tuple(bpy.data.objects)  # Get all objects from all Scenes

            try:
                result = _export.batch_export(self, init_obj_list)
            except Exception as e:

                result = {"CANCELLED"}
                context.window.cursor_modal_restore()

                import traceback

                traceback.print_exc()
                lprint("E Unexpected %r accured during batch export, see stack trace above.",
                       (type(e).__name__,),
                       report_errors=1,
                       report_warnings=1)

            return result
示例#9
0
        def execute_export(self, context, disable_local_view):
            """Actually executes export of current selected objects (bpy.context.selected_objects)

            :param context: operator context
            :type context: bpy_struct
            :param disable_local_view: True if you want to disable local view after export
            :type disable_local_view: bool
            :return: succes of batch export
            :rtype: {'FINISHED'} | {'CANCELLED'}
            """

            init_obj_list = ()
            export_scope = _get_scs_globals().export_scope
            if export_scope == "selection":
                init_obj_list = tuple(bpy.context.selected_objects)
            elif export_scope == "scene":
                init_obj_list = tuple(bpy.context.scene.objects)
            elif export_scope == "scenes":
                init_obj_list = tuple(bpy.data.objects)

            try:
                result = _export.batch_export(self, init_obj_list)
            except Exception as e:

                result = {"CANCELLED"}
                context.window.cursor_modal_restore()

                import traceback

                traceback.print_exc()
                lprint("E Unexpected %r accured during batch export, see stack trace above.",
                       (type(e).__name__,),
                       report_errors=1,
                       report_warnings=1)

            if disable_local_view:
                _view3d_utils.switch_local_view(False)

            return result