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
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
def invoke(self, context, event): if len(context.selected_objects) != 0: # show preview or directly execute export if context.scene.scs_props.preview_export_selection: _view3d_utils.switch_local_view(True) context.window_manager.modal_handler_add(self) return {'RUNNING_MODAL'} else: return self.execute_export(context, False) else: self.report({'ERROR'}, "Nothing to export!") return {'FINISHED'}
def invoke(self, context, event): # show preview or directly execute export if _get_scs_globals().export_scope == "selection": if _get_scs_globals().preview_export_selection: if len(context.selected_objects) == 0: print(self.not_root_objs) if len(self.not_root_objs) > 0: msg = "Selected objects are not part of any SCS Game Object!" else: msg = "Nothing selected!" self.report({'ERROR'}, msg) return {'FINISHED'} _view3d_utils.switch_local_view(True) context.window_manager.modal_handler_add(self) return {'RUNNING_MODAL'} return self.execute_export(context, False)
def modal(self, context, event): if event.type in ('WHEELUPMOUSE', 'NUMPAD_PLUS'): self.execute_zoom(-1) elif event.type in ('WHEELDOWNMOUSE', 'NUMPAD_MINUS'): self.execute_zoom(1) elif event.type == 'NUMPAD_4': self.execute_rotation("ORBITLEFT") elif event.type == 'NUMPAD_6': self.execute_rotation("ORBITRIGHT") elif event.type == 'NUMPAD_8': self.execute_rotation("ORBITUP") elif event.type == 'NUMPAD_2': self.execute_rotation("ORBITDOWN") elif event.type in ('RET', 'NUMPAD_ENTER'): return self.execute_export(context, True) elif event.type == 'ESC': _view3d_utils.switch_local_view(False) return {'CANCELLED'} return {'RUNNING_MODAL'}
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