Skip to content

Commit 6aa7d2b

Browse files
add a smoothing enum explicitly for FBX export and make sure other formats were exporting smoothing data correctly on export
1 parent 7303b6b commit 6aa7d2b

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

operators.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,7 @@ def export_object(obj, file_path, scene_props):
700700
object_types={"MESH"},
701701
path_mode="COPY",
702702
embed_textures=True,
703+
mesh_smooth_type=scene_props.mesh_export_smoothing,
703704
use_mesh_modifiers=False, # Handled by apply_mesh_modifiers
704705
use_triangles=False, # Handled by triangulate_mesh
705706
)
@@ -712,6 +713,8 @@ def export_object(obj, file_path, scene_props):
712713
up_axis=scene_props.mesh_export_coord_up,
713714
export_materials=True,
714715
path_mode="COPY",
716+
export_normals=True,
717+
export_smooth_groups=True,
715718
apply_modifiers=False, # Handled by apply_mesh_modifiers
716719
export_triangulated_mesh=False, # Handled triangulate_mesh
717720
)
@@ -722,6 +725,7 @@ def export_object(obj, file_path, scene_props):
722725
export_format="GLTF_SEPARATE", # or GLB
723726
export_apply=False, # Transforms/Mods applied manually
724727
export_attributes=True,
728+
export_normals=True,
725729
export_extras=True,
726730
export_yup=(scene_props.mesh_export_coord_up == "Y"),
727731
# Need to add a prop to track material quality
@@ -738,6 +742,7 @@ def export_object(obj, file_path, scene_props):
738742
scene_props.mesh_export_coord_up),
739743
export_meshes=True,
740744
export_materials=True,
745+
export_normals=True,
741746
generate_preview_surface=False,
742747
use_instancing=False,
743748
evaluation_mode="RENDER",
@@ -752,6 +757,7 @@ def export_object(obj, file_path, scene_props):
752757
bpy.ops.wm.stl_export(
753758
filepath=export_filepath,
754759
export_selected_objects=True,
760+
use_selection=True,
755761
global_scale=1.0, # Scale applied setup_export_object
756762
forward_axis=scene_props.mesh_export_coord_forward,
757763
up_axis=scene_props.mesh_export_coord_up,

panels.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ def format_has_scale(self, format):
3535
def format_has_coordinates(self, format):
3636
"""Check if the format is compatible with coordinate export settings"""
3737
return format in {"FBX", "OBJ", "USD", "STL"}
38+
39+
def format_has_smoothing(self, format):
40+
"""Check if the format is compatible with smoothing export settings"""
41+
return format in {"FBX"}
3842

3943

4044
def draw(self, context):
@@ -88,6 +92,13 @@ def draw(self, context):
8892
row = col.row(align=True)
8993
row.prop(settings, "mesh_export_units", expand=True)
9094

95+
# Smoothing settings
96+
if self.format_has_smoothing(settings.mesh_export_format):
97+
# Only show if the format supports smoothing
98+
col = layout.column(heading="Smoothing", align=True)
99+
row = col.row(align=True)
100+
row.prop(settings, "mesh_export_smoothing", expand=True)
101+
91102
# Zero location settings
92103
col = layout.column(align=True)
93104
col.prop(settings, "mesh_export_zero_location")

properties.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,18 @@ class MeshExporterSettings(PropertyGroup):
8080
default="X"
8181
)
8282

83+
mesh_export_smoothing: EnumProperty(
84+
name="Smoothing",
85+
description="Smoothing method for exported meshes",
86+
items=[
87+
("OFF", "Off", "Export only normals instead "
88+
"of writing edge or face smoothing data"),
89+
("FACE", "Face", "Write face smoothing"),
90+
("EDGE", "Edge", "Write edge smoothing"),
91+
],
92+
default="FACE"
93+
)
94+
8395
# Zero location property
8496
mesh_export_zero_location: BoolProperty(
8597
name="Zero Location",

0 commit comments

Comments
 (0)