diff --git a/cg/blender/export/__init__.py b/cg/blender/export/__init__.py index 7743945..506b048 100644 --- a/cg/blender/export/__init__.py +++ b/cg/blender/export/__init__.py @@ -27,6 +27,9 @@ def export_decorator(func): def wrapper(**kwargs): bpy.ops.object.select_all(action='DESELECT') # add defaults + kwargs.setdefault('global_scale', 1000) + kwargs.setdefault('axis_forward', 'Y') + kwargs.setdefault('axis_up', 'Z') kwargs.setdefault('path', '//') kwargs.setdefault('subdir', '') diff --git a/cg/blender/export/dae.py b/cg/blender/export/dae.py index 95f8e62..c9e380f 100644 --- a/cg/blender/export/dae.py +++ b/cg/blender/export/dae.py @@ -30,8 +30,8 @@ def export_dae(**kwargs): apply_modifiers=True, export_mesh_type=0, export_mesh_type_selection='view', - export_global_forward_selection='Y', - export_global_up_selection='Z', + export_global_forward_selection=kwargs['axis_forward'], + export_global_up_selection=kwargs['axis_up'], apply_global_orientation=False, selected=True, include_children=False, diff --git a/cg/blender/export/obj.py b/cg/blender/export/obj.py index 0459e32..b1f4d50 100644 --- a/cg/blender/export/obj.py +++ b/cg/blender/export/obj.py @@ -4,6 +4,7 @@ DESCRIPTION. OBJ mesh exporter. Exports all objects in scene. You can set export path and subdir. +DEPRECATED """ __version__ = "0.2" diff --git a/cg/blender/export/ply.py b/cg/blender/export/ply.py new file mode 100644 index 0000000..41677d2 --- /dev/null +++ b/cg/blender/export/ply.py @@ -0,0 +1,40 @@ +# coding: utf-8 +# Copyright (C) 2023 Ilia Kurochkin +# +# 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. +PLY mesh exporter. +''' +__version__ = "0.2" + +import bpy +from blender.export import export_decorator + + +@export_decorator +def export_ply(**kwargs): + outpath = ('{}.ply'.format(kwargs['outpath'])) + + bpy.ops.export_mesh.ply(filepath=outpath, + check_existing=False, + filter_glob="*.ply", + use_ascii=True, + use_selection=True, + use_mesh_modifiers=True, + use_normals=True, + use_uv_coords=True, + use_colors=True, + global_scale=kwargs['global_scale'], + axis_forward=kwargs['axis_forward'], + axis_up=kwargs['axis_up']) + + return outpath diff --git a/cg/blender/export/stl.py b/cg/blender/export/stl.py index a9cefc3..2a526ba 100644 --- a/cg/blender/export/stl.py +++ b/cg/blender/export/stl.py @@ -28,12 +28,12 @@ def export_stl(**kwargs): check_existing=False, filter_glob='*.stl', use_selection=True, - global_scale=1000, + global_scale=kwargs['global_scale'], use_scene_unit=False, ascii=False, use_mesh_modifiers=True, batch_mode='OFF', - axis_forward='Y', - axis_up='Z') + axis_forward=kwargs['axis_forward'], + axis_up=kwargs['axis_up']) return outpath