From 25ce954c0d096cecea8fd3308a8d308c821b86fe Mon Sep 17 00:00:00 2001 From: foreachthing Date: Thu, 18 Jul 2024 22:15:54 +0200 Subject: [PATCH] Added ASCII export functionality for STL and PLY. --- .gitignore | 4 ++++ source/__init__.py | 5 +++++ source/export.py | 4 ++-- source/ui.py | 3 +++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 1a49cd0..fa122ea 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ # Generic files to ignore. .* +print3d.rsa +print3d.rsa.pub + # Python temp paths. __pycache__/ *.py[cod] @@ -17,3 +20,4 @@ __pycache__/ # Locally built extensions. /*.zip + diff --git a/source/__init__.py b/source/__init__.py index 2ecc830..7d09d54 100644 --- a/source/__init__.py +++ b/source/__init__.py @@ -47,6 +47,11 @@ class SceneProperties(PropertyGroup): description="Apply scene scale setting on export", default=False, ) + use_ascii_export: BoolProperty( + name="ASCII", + description="Exporting file in ASCII format, export binary as binary otherwise.", + default=False, + ) use_data_layers: BoolProperty( name="Data Layers", description=( diff --git a/source/export.py b/source/export.py index 740c675..099bf1d 100644 --- a/source/export.py +++ b/source/export.py @@ -100,7 +100,7 @@ def write_mesh(context, report_cb): filepath = bpy.path.ensure_ext(filepath, ".stl") ret = bpy.ops.wm.stl_export( filepath=filepath, - ascii_format=False, + ascii_format=print_3d.use_ascii_export, apply_modifiers=True, export_selected_objects=True, global_scale=global_scale, @@ -109,7 +109,7 @@ def write_mesh(context, report_cb): filepath = bpy.path.ensure_ext(filepath, ".ply") ret = bpy.ops.wm.ply_export( filepath=filepath, - ascii_format=False, + ascii_format=print_3d.use_ascii_export, apply_modifiers=True, export_selected_objects=True, global_scale=global_scale, diff --git a/source/ui.py b/source/ui.py index 19995de..e08b711 100644 --- a/source/ui.py +++ b/source/ui.py @@ -135,6 +135,9 @@ class VIEW3D_PT_print3d_export(View3DPrintPanel, Panel): col.prop(print_3d, "use_apply_scale") col.prop(print_3d, "use_export_texture") sub = col.column() + sub.active = print_3d.export_format in ("STL", "PLY") + sub.prop(print_3d, "use_ascii_export") + sub = col.column() sub.active = print_3d.export_format != "STL" sub.prop(print_3d, "use_data_layers") -- 2.30.2