# coding: utf-8
# Copyright (C) 2023 Ilia Kurochkin <brothermechanic@yandex.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
'''
DESCRIPTION.
STL mesh exporter.
'''
__version__ = "0.2"

import bpy
from blender.export import export_decorator


@export_decorator
def export_stl(**kwargs):
    outpath = ('{}.stl'.format(kwargs['outpath']))

    bpy.ops.export_mesh.stl(filepath=outpath,
                            check_existing=False,
                            filter_glob='*.stl',
                            use_selection=True,
                            global_scale=kwargs['global_scale'],
                            use_scene_unit=False,
                            ascii=False,
                            use_mesh_modifiers=True,
                            batch_mode='OFF',
                            axis_forward=kwargs['axis_forward'],
                            axis_up=kwargs['axis_up'])

    return outpath
