Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Rachinskiy <mikhail.rachinskiy@gmail.com>2021-05-14 14:12:47 +0300
committerMikhail Rachinskiy <mikhail.rachinskiy@gmail.com>2021-05-14 14:12:47 +0300
commit8f1c831af6419c469f5da22e013e67163662b15d (patch)
tree32162360179e20948e6acbbe68e8cb0bcc7d3ed2 /object_print3d_utils
parentbb16aba5bd3873794eefe167497118b6063b9a85 (diff)
3D-Print: new export option Data Layers
Enables export of normals, UVs, vertex colors and materials for formats that support it. Disabled by default to reduce filesize.
Diffstat (limited to 'object_print3d_utils')
-rw-r--r--object_print3d_utils/__init__.py11
-rw-r--r--object_print3d_utils/export.py18
-rw-r--r--object_print3d_utils/ui.py5
3 files changed, 26 insertions, 8 deletions
diff --git a/object_print3d_utils/__init__.py b/object_print3d_utils/__init__.py
index 9a2aefbe..87a69155 100644
--- a/object_print3d_utils/__init__.py
+++ b/object_print3d_utils/__init__.py
@@ -61,10 +61,10 @@ class SceneProperties(PropertyGroup):
name="Format",
description="Format type to export to",
items=(
- ('STL', "STL", ""),
+ ('OBJ', "OBJ", ""),
('PLY', "PLY", ""),
+ ('STL', "STL", ""),
('X3D', "X3D", ""),
- ('OBJ', "OBJ", ""),
),
default='STL',
)
@@ -78,6 +78,13 @@ class SceneProperties(PropertyGroup):
description="Apply scene scale setting on export",
default=False,
)
+ use_data_layers: BoolProperty(
+ name="Data Layers",
+ description=(
+ "Export normals, UVs, vertex colors and materials for formats that support it "
+ "significantly increasing filesize"
+ ),
+ )
export_path: StringProperty(
name="Export Directory",
description="Path to directory where the files are created",
diff --git a/object_print3d_utils/export.py b/object_print3d_utils/export.py
index fc225ccc..2f846aaf 100644
--- a/object_print3d_utils/export.py
+++ b/object_print3d_utils/export.py
@@ -81,6 +81,7 @@ def write_mesh(context, report_cb):
path_mode = 'COPY' if print_3d.use_export_texture else 'AUTO'
export_path = bpy.path.abspath(print_3d.export_path)
obj = layer.objects.active
+ export_data_layers = print_3d.use_data_layers
# Create name 'export_path/blendname-objname'
# add the filename component
@@ -129,9 +130,13 @@ def write_mesh(context, report_cb):
filepath = bpy.path.ensure_ext(filepath, ".ply")
ret = bpy.ops.export_mesh.ply(
filepath=filepath,
+ use_ascii=False,
use_mesh_modifiers=True,
use_selection=True,
global_scale=global_scale,
+ use_normals=export_data_layers,
+ use_uv_coords=export_data_layers,
+ use_colors=export_data_layers,
)
elif export_format == 'X3D':
addon_ensure("io_scene_x3d")
@@ -140,8 +145,9 @@ def write_mesh(context, report_cb):
filepath=filepath,
use_mesh_modifiers=True,
use_selection=True,
- path_mode=path_mode,
global_scale=global_scale,
+ path_mode=path_mode,
+ use_normals=export_data_layers,
)
elif export_format == 'OBJ':
addon_ensure("io_scene_obj")
@@ -150,16 +156,18 @@ def write_mesh(context, report_cb):
filepath=filepath,
use_mesh_modifiers=True,
use_selection=True,
- path_mode=path_mode,
global_scale=global_scale,
+ path_mode=path_mode,
+ use_normals=export_data_layers,
+ use_uvs=export_data_layers,
+ use_materials=export_data_layers,
)
else:
assert 0
# for formats that don't support images
- if export_format in {'STL', 'PLY'}:
- if path_mode == 'COPY':
- image_copy_guess(filepath, context.selected_objects)
+ if path_mode == 'COPY' and export_format in {'STL', 'PLY'}:
+ image_copy_guess(filepath, context.selected_objects)
if 'FINISHED' in ret:
if report_cb is not None:
diff --git a/object_print3d_utils/ui.py b/object_print3d_utils/ui.py
index 83dda62b..6a0f6d6f 100644
--- a/object_print3d_utils/ui.py
+++ b/object_print3d_utils/ui.py
@@ -143,10 +143,13 @@ class VIEW3D_PT_print3d_export(View3DPrintPanel, Panel):
print_3d = context.scene.print_3d
layout.prop(print_3d, "export_path", text="")
+ layout.prop(print_3d, "export_format")
col = layout.column()
col.prop(print_3d, "use_apply_scale")
col.prop(print_3d, "use_export_texture")
+ sub = col.column()
+ sub.active = print_3d.export_format != "STL"
+ sub.prop(print_3d, "use_data_layers")
- layout.prop(print_3d, "export_format")
layout.operator("mesh.print3d_export", text="Export", icon='EXPORT')