Import_3ds: Remove None from object list #104783

Merged
Sebastian Sille merged 23 commits from :main into main 2023-07-27 18:11:43 +02:00
2 changed files with 23 additions and 10 deletions
Showing only changes of commit b7a36d80d5 - Show all commits

View File

@ -18,7 +18,7 @@ import bpy
bl_info = { bl_info = {
"name": "Autodesk 3DS format", "name": "Autodesk 3DS format",
"author": "Bob Holcomb, Campbell Barton, Andreas Atteneder, Sebastian Schrand", "author": "Bob Holcomb, Campbell Barton, Andreas Atteneder, Sebastian Schrand",
"version": (2, 4, 4), "version": (2, 4, 5),
"blender": (3, 6, 0), "blender": (3, 6, 0),
"location": "File > Import-Export", "location": "File > Import-Export",
"description": "3DS Import/Export meshes, UVs, materials, textures, " "description": "3DS Import/Export meshes, UVs, materials, textures, "
@ -170,14 +170,14 @@ class Export3DS(bpy.types.Operator, ExportHelper):
) )
scale_factor: FloatProperty( scale_factor: FloatProperty(
name="Scale", name="Scale Factor",
description="Scale factor for all objects", description="Master scale factor for all objects",
min=0.0, max=100000.0, min=0.0, max=100000.0,
soft_min=0.0, soft_max=100000.0, soft_min=0.0, soft_max=100000.0,
default=1.0, default=1.0,
) )
apply_unit: BoolProperty( apply_unit: BoolProperty(
name="Apply Units", name="Scene Units",
description="Take the scene unit length settings into account", description="Take the scene unit length settings into account",
default=False, default=False,
) )
@ -186,13 +186,23 @@ class Export3DS(bpy.types.Operator, ExportHelper):
description="Export selected objects only", description="Export selected objects only",
default=False, default=False,
) )
object_filter: bpy.props.EnumProperty(
name="Object Filter", options={'ENUM_FLAG'},
items=(('MESH',"Mesh".rjust(11),"",'MESH_DATA',0x1),
('LIGHT',"Light".rjust(12),"",'LIGHT_DATA',0x2),
('CAMERA',"Camera".rjust(11),"",'CAMERA_DATA',0x4),
('EMPTY',"Empty".rjust(11),"",'EMPTY_DATA',0x8),
),
description="Object types to export",
default={'MESH', 'LIGHT', 'CAMERA', 'EMPTY'},
)
use_hierarchy: BoolProperty( use_hierarchy: BoolProperty(
name="Export Hierarchy", name="Export Hierarchy",
description="Export hierarchy chunks", description="Export hierarchy chunks",
default=False, default=False,
) )
write_keyframe: BoolProperty( write_keyframe: BoolProperty(
name="Write Keyframe", name="Export Keyframes",
description="Write the keyframe data", description="Write the keyframe data",
default=False, default=False,
) )
@ -238,7 +248,10 @@ class MAX3DS_PT_export_include(bpy.types.Panel):
operator = sfile.active_operator operator = sfile.active_operator
layout.prop(operator, "use_selection") layout.prop(operator, "use_selection")
layout.prop(operator, "use_hierarchy") laysub = layout.column(align=True)
laysub.enabled = (not operator.use_selection)
laysub.prop(operator, "object_filter")
layout.column().prop(operator, "use_hierarchy")
layout.prop(operator, "write_keyframe") layout.prop(operator, "write_keyframe")

View File

@ -1489,8 +1489,8 @@ def make_ambient_node(world):
# EXPORT # # EXPORT #
########## ##########
def save(operator, context, filepath="", scale_factor=1.0, apply_unit=False, def save(operator, context, filepath="", scale_factor=1.0, apply_unit=False, use_selection=False,
use_selection=False, use_hierarchy=False, write_keyframe=False, global_matrix=None): object_filter=None, 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."""
# Time the export # Time the export
@ -1504,7 +1504,7 @@ def save(operator, context, filepath="", scale_factor=1.0, apply_unit=False,
unit_measure = 1.0 unit_measure = 1.0
if apply_unit: if apply_unit:
unit_length = sce.unit_settings.length_unit unit_length = scene.unit_settings.length_unit
if unit_length == 'KILOMETERS': if unit_length == 'KILOMETERS':
unit_measure = 0.001 unit_measure = 0.001
elif unit_length == 'CENTIMETERS': elif unit_length == 'CENTIMETERS':
@ -1566,7 +1566,7 @@ def save(operator, context, filepath="", scale_factor=1.0, apply_unit=False,
if use_selection: if use_selection:
objects = [ob for ob in scene.objects if ob.visible_get(view_layer=layer) and ob.select_get(view_layer=layer)] objects = [ob for ob in scene.objects if ob.visible_get(view_layer=layer) and ob.select_get(view_layer=layer)]
else: else:
objects = [ob for ob in scene.objects if ob.visible_get(view_layer=layer)] objects = [ob for ob in scene.objects if ob.type in object_filter and ob.visible_get(view_layer=layer)]
empty_objects = [ob for ob in objects if ob.type == 'EMPTY'] empty_objects = [ob for ob in objects if ob.type == 'EMPTY']
light_objects = [ob for ob in objects if ob.type == 'LIGHT'] light_objects = [ob for ob in objects if ob.type == 'LIGHT']