Import_3ds: Avoid any None in object lists #104785

Merged
Sebastian Sille merged 26 commits from :main into main 2023-07-27 18:46:27 +02:00
2 changed files with 22 additions and 3 deletions
Showing only changes of commit 31c673f607 - Show all commits

View File

@ -176,6 +176,11 @@ class Export3DS(bpy.types.Operator, ExportHelper):
soft_min=0.0, soft_max=100000.0, soft_min=0.0, soft_max=100000.0,
default=1.0, default=1.0,
) )
unit_convert: BoolProperty(
name="Convert Units",
description="Converts to scene unit length settings",
default=False,
)
use_selection: BoolProperty( use_selection: BoolProperty(
name="Selection Only", name="Selection Only",
description="Export selected objects only", description="Export selected objects only",
@ -259,6 +264,7 @@ class MAX3DS_PT_export_transform(bpy.types.Panel):
operator = sfile.active_operator operator = sfile.active_operator
layout.prop(operator, "scale_factor") layout.prop(operator, "scale_factor")
layout.prop(operator, "unit_convert")
layout.prop(operator, "axis_forward") layout.prop(operator, "axis_forward")
layout.prop(operator, "axis_up") layout.prop(operator, "axis_up")

View File

@ -1489,10 +1489,9 @@ def make_ambient_node(world):
# EXPORT # # EXPORT #
########## ##########
def save(operator, context, filepath="", scale_factor=1.0, use_selection=False, use_hierarchy=False, write_keyframe=False, global_matrix=None): def save(operator, context, filepath="", scale_factor=1.0, convert_unit=False,
use_selection=False, use_hierarchy=False, write_keyframe=False, global_matrix=None):
"""Save the Blender scene to a 3ds file.""" """Save the Blender scene to a 3ds file."""
mtx_scale = mathutils.Matrix.Scale(scale_factor, 4)
# Time the export # Time the export
duration = time.time() duration = time.time()
@ -1503,6 +1502,20 @@ def save(operator, context, filepath="", scale_factor=1.0, use_selection=False,
depsgraph = context.evaluated_depsgraph_get() depsgraph = context.evaluated_depsgraph_get()
world = scene.world world = scene.world
unit_measure = 1.0
if unit_convert:
unit_length = sce.unit_settings.length_unit
if unit_length == 'KILOMETERS':
unit_measure = 0.001
elif unit_length == 'CENTIMETERS':
unit_measure = 100
elif unit_length == 'MILLIMETERS':
unit_measure = 1000
elif unit_length == 'MICROMETERS':
unit_measure = 1000000
mtx_scale = mathutils.Matrix.Scale((scale_factor * unit_measure),4)
if global_matrix is None: if global_matrix is None:
global_matrix = mathutils.Matrix() global_matrix = mathutils.Matrix()