Skip to content

Commit b7cd56a

Browse files
fix axis parameters when values are negative for obj, stl, and usd
1 parent 5ad3477 commit b7cd56a

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

operators.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,6 +1245,13 @@ def export_object(obj, file_path, scene_props, export_scale=1.0):
12451245
f"Exporting {os.path.basename(export_filepath)} ({fmt}) - {mesh_size:,} polygons..."
12461246
)
12471247

1248+
# Convert axis values for OBJ and STL export
1249+
def convert_axis_for_export(axis_value):
1250+
"""Convert axis values like '-Z' to 'NEGATIVE_Z' for OBJ/STL export."""
1251+
if axis_value.startswith('-'):
1252+
return f"NEGATIVE_{axis_value[1]}"
1253+
return axis_value
1254+
12481255
with temp_selection_context(bpy.context, active_object=obj,
12491256
selected_objects=[obj]):
12501257
try:
@@ -1269,8 +1276,8 @@ def export_object(obj, file_path, scene_props, export_scale=1.0):
12691276
filepath=export_filepath,
12701277
export_selected_objects=True,
12711278
global_scale=export_scale, # Pass scale to exporter instead of applying to mesh
1272-
forward_axis=scene_props.mesh_export_coord_forward,
1273-
up_axis=scene_props.mesh_export_coord_up,
1279+
forward_axis=convert_axis_for_export(scene_props.mesh_export_coord_forward),
1280+
up_axis=convert_axis_for_export(scene_props.mesh_export_coord_up),
12741281
export_materials=True,
12751282
path_mode="STRIP", # OBJ doesn't embed textures
12761283
export_normals=True,
@@ -1323,9 +1330,9 @@ def export_object(obj, file_path, scene_props, export_scale=1.0):
13231330
filepath=export_filepath,
13241331
selected_objects_only=True,
13251332
export_global_forward_selection=(
1326-
scene_props.mesh_export_coord_forward),
1333+
convert_axis_for_export(scene_props.mesh_export_coord_forward)),
13271334
export_global_up_selection=(
1328-
scene_props.mesh_export_coord_up),
1335+
convert_axis_for_export(scene_props.mesh_export_coord_up)),
13291336
export_meshes=True,
13301337
export_materials=True,
13311338
export_normals=True,
@@ -1344,8 +1351,8 @@ def export_object(obj, file_path, scene_props, export_scale=1.0):
13441351
filepath=export_filepath,
13451352
export_selected_objects=True,
13461353
global_scale=export_scale, # Pass scale to exporter instead of applying to mesh
1347-
forward_axis=scene_props.mesh_export_coord_forward,
1348-
up_axis=scene_props.mesh_export_coord_up,
1354+
forward_axis=convert_axis_for_export(scene_props.mesh_export_coord_forward),
1355+
up_axis=convert_axis_for_export(scene_props.mesh_export_coord_up),
13491356
apply_modifiers=False, # Handled by apply_mesh_modifiers
13501357
)
13511358
else:

0 commit comments

Comments
 (0)