New addon: Import_max #19
@ -38,35 +38,56 @@ if "bpy" in locals():
|
|||||||
@orientation_helper(axis_forward='Y', axis_up='Z')
|
@orientation_helper(axis_forward='Y', axis_up='Z')
|
||||||
class Import3DS(bpy.types.Operator, ImportHelper):
|
class Import3DS(bpy.types.Operator, ImportHelper):
|
||||||
"""Import from 3DS file format (.3ds)"""
|
"""Import from 3DS file format (.3ds)"""
|
||||||
bl_idname = "import_scene.autodesk_3ds"
|
bl_idname = "import_scene.max3ds"
|
||||||
bl_label = 'Import 3DS'
|
bl_label = 'Import 3DS'
|
||||||
bl_options = {'UNDO'}
|
bl_options = {'PRESET', 'UNDO'}
|
||||||
|
|
||||||
filename_ext = ".3ds"
|
filename_ext = ".3ds"
|
||||||
filter_glob: StringProperty(default="*.3ds", options={'HIDDEN'})
|
filter_glob: StringProperty(default="*.3ds", options={'HIDDEN'})
|
||||||
|
|
||||||
constrain_size: FloatProperty(
|
constrain_size: FloatProperty(
|
||||||
name="Size Constraint",
|
name="Constrain Size",
|
||||||
description="Scale the model by 10 until it reaches the "
|
description="Scale the model by 10 until it reaches the "
|
||||||
"size constraint (0 to disable)",
|
"size constraint (0 to disable)",
|
||||||
min=0.0, max=1000.0,
|
min=0.0, max=1000.0,
|
||||||
soft_min=0.0, soft_max=1000.0,
|
soft_min=0.0, soft_max=1000.0,
|
||||||
default=10.0,
|
default=10.0,
|
||||||
)
|
)
|
||||||
|
use_scene_unit: BoolProperty(
|
||||||
|
name="Scene Units",
|
||||||
|
description="Convert to scene unit length settings",
|
||||||
|
default=False,
|
||||||
|
)
|
||||||
|
use_center_pivot: BoolProperty(
|
||||||
|
name="Pivot Origin",
|
||||||
|
description="Move all geometry to pivot origin",
|
||||||
|
default=False,
|
||||||
|
)
|
||||||
use_image_search: BoolProperty(
|
use_image_search: BoolProperty(
|
||||||
name="Image Search",
|
name="Image Search",
|
||||||
description="Search subdirectories for any associated images "
|
description="Search subdirectories for any associated images "
|
||||||
"(Warning, may be slow)",
|
"(Warning, may be slow)",
|
||||||
default=True,
|
default=True,
|
||||||
)
|
)
|
||||||
|
object_filter: EnumProperty(
|
||||||
|
name="Object Filter", options={'ENUM_FLAG'},
|
||||||
|
items=(('WORLD', "World".rjust(11), "", 'WORLD_DATA', 0x1),
|
||||||
|
('MESH', "Mesh".rjust(11), "", 'MESH_DATA', 0x2),
|
||||||
|
('LIGHT', "Light".rjust(12), "", 'LIGHT_DATA', 0x4),
|
||||||
|
('CAMERA', "Camera".rjust(11), "", 'CAMERA_DATA', 0x8),
|
||||||
|
('EMPTY', "Empty".rjust(11), "", 'EMPTY_AXIS', 0x10),
|
||||||
|
),
|
||||||
|
description="Object types to import",
|
||||||
|
default={'WORLD', 'MESH', 'LIGHT', 'CAMERA', 'EMPTY'},
|
||||||
|
)
|
||||||
use_apply_transform: BoolProperty(
|
use_apply_transform: BoolProperty(
|
||||||
name="Apply Transform",
|
name="Apply Transform",
|
||||||
description="Workaround for object transformations "
|
description="Workaround for object transformations "
|
||||||
"importing incorrectly",
|
"importing incorrectly",
|
||||||
default=True,
|
default=True,
|
||||||
)
|
)
|
||||||
read_keyframe: BoolProperty(
|
use_keyframes: BoolProperty(
|
||||||
name="Read Keyframe",
|
name="Animation",
|
||||||
description="Read the keyframe data",
|
description="Read the keyframe data",
|
||||||
default=True,
|
default=True,
|
||||||
)
|
)
|
||||||
@ -75,6 +96,11 @@ class Import3DS(bpy.types.Operator, ImportHelper):
|
|||||||
description="Transform to matrix world",
|
description="Transform to matrix world",
|
||||||
default=False,
|
default=False,
|
||||||
)
|
)
|
||||||
|
use_cursor: BoolProperty(
|
||||||
|
name="Cursor Origin",
|
||||||
|
description="Read the 3D cursor location",
|
||||||
|
default=False,
|
||||||
|
)
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
from . import import_3ds
|
from . import import_3ds
|
||||||
@ -91,12 +117,87 @@ class Import3DS(bpy.types.Operator, ImportHelper):
|
|||||||
|
|
||||||
return import_3ds.load(self, context, **keywords)
|
return import_3ds.load(self, context, **keywords)
|
||||||
|
|
||||||
|
def draw(self, context):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class MAX3DS_PT_import_include(bpy.types.Panel):
|
||||||
|
bl_space_type = 'FILE_BROWSER'
|
||||||
|
bl_region_type = 'TOOL_PROPS'
|
||||||
|
bl_label = "Include"
|
||||||
|
bl_parent_id = "FILE_PT_operator"
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def poll(cls, context):
|
||||||
|
sfile = context.space_data
|
||||||
|
operator = sfile.active_operator
|
||||||
|
|
||||||
|
return operator.bl_idname == "IMPORT_SCENE_OT_max3ds"
|
||||||
|
|
||||||
|
def draw(self, context):
|
||||||
|
layout = self.layout
|
||||||
|
layout.use_property_split = True
|
||||||
|
layout.use_property_decorate = True
|
||||||
|
|
||||||
|
sfile = context.space_data
|
||||||
|
operator = sfile.active_operator
|
||||||
|
|
||||||
|
layrow = layout.row(align=True)
|
||||||
|
layrow.prop(operator, "use_image_search")
|
||||||
|
layrow.label(text="", icon='OUTLINER_OB_IMAGE' if operator.use_image_search else 'IMAGE_DATA')
|
||||||
|
layout.column().prop(operator, "object_filter")
|
||||||
|
layrow = layout.row(align=True)
|
||||||
|
layrow.prop(operator, "use_keyframes")
|
||||||
|
layrow.label(text="", icon='ANIM' if operator.use_keyframes else 'DECORATE_DRIVER')
|
||||||
|
layrow = layout.row(align=True)
|
||||||
|
layrow.prop(operator, "use_cursor")
|
||||||
|
layrow.label(text="", icon='PIVOT_CURSOR' if operator.use_cursor else 'CURSOR')
|
||||||
|
|
||||||
|
|
||||||
|
class MAX3DS_PT_import_transform(bpy.types.Panel):
|
||||||
|
bl_space_type = 'FILE_BROWSER'
|
||||||
|
bl_region_type = 'TOOL_PROPS'
|
||||||
|
bl_label = "Transform"
|
||||||
|
bl_parent_id = "FILE_PT_operator"
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def poll(cls, context):
|
||||||
|
sfile = context.space_data
|
||||||
|
operator = sfile.active_operator
|
||||||
|
|
||||||
|
return operator.bl_idname == "IMPORT_SCENE_OT_max3ds"
|
||||||
|
|
||||||
|
def draw(self, context):
|
||||||
|
layout = self.layout
|
||||||
|
layout.use_property_split = True
|
||||||
|
layout.use_property_decorate = False
|
||||||
|
|
||||||
|
sfile = context.space_data
|
||||||
|
operator = sfile.active_operator
|
||||||
|
|
||||||
|
layout.prop(operator, "constrain_size")
|
||||||
|
layrow = layout.row(align=True)
|
||||||
|
layrow.prop(operator, "use_scene_unit")
|
||||||
|
layrow.label(text="", icon='EMPTY_ARROWS' if operator.use_scene_unit else 'EMPTY_DATA')
|
||||||
|
layrow = layout.row(align=True)
|
||||||
|
layrow.prop(operator, "use_center_pivot")
|
||||||
|
layrow.label(text="", icon='OVERLAY' if operator.use_center_pivot else 'PIVOT_ACTIVE')
|
||||||
|
layrow = layout.row(align=True)
|
||||||
|
layrow.prop(operator, "use_apply_transform")
|
||||||
|
layrow.label(text="", icon='MESH_CUBE' if operator.use_apply_transform else 'MOD_SOLIDIFY')
|
||||||
|
layrow = layout.row(align=True)
|
||||||
|
layrow.prop(operator, "use_world_matrix")
|
||||||
|
layrow.label(text="", icon='WORLD' if operator.use_world_matrix else 'META_BALL')
|
||||||
|
layout.prop(operator, "axis_forward")
|
||||||
|
layout.prop(operator, "axis_up")
|
||||||
|
|
||||||
|
|
||||||
@orientation_helper(axis_forward='Y', axis_up='Z')
|
@orientation_helper(axis_forward='Y', axis_up='Z')
|
||||||
class Export3DS(bpy.types.Operator, ExportHelper):
|
class Export3DS(bpy.types.Operator, ExportHelper):
|
||||||
"""Export to 3DS file format (.3ds)"""
|
"""Export to 3DS file format (.3ds)"""
|
||||||
bl_idname = "export_scene.autodesk_3ds"
|
bl_idname = "export_scene.max3ds"
|
||||||
bl_label = 'Export 3DS'
|
bl_label = 'Export 3DS'
|
||||||
|
bl_options = {'PRESET', 'UNDO'}
|
||||||
|
|
||||||
filename_ext = ".3ds"
|
filename_ext = ".3ds"
|
||||||
filter_glob: StringProperty(
|
filter_glob: StringProperty(
|
||||||
@ -104,16 +205,49 @@ class Export3DS(bpy.types.Operator, ExportHelper):
|
|||||||
options={'HIDDEN'},
|
options={'HIDDEN'},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
scale_factor: FloatProperty(
|
||||||
|
name="Scale Factor",
|
||||||
|
description="Master scale factor for all objects",
|
||||||
|
min=0.0, max=100000.0,
|
||||||
|
soft_min=0.0, soft_max=100000.0,
|
||||||
|
default=1.0,
|
||||||
|
)
|
||||||
|
use_scene_unit: BoolProperty(
|
||||||
|
name="Scene Units",
|
||||||
|
description="Take the scene unit length settings into account",
|
||||||
|
default=False,
|
||||||
|
)
|
||||||
use_selection: BoolProperty(
|
use_selection: BoolProperty(
|
||||||
name="Selection Only",
|
name="Selection",
|
||||||
description="Export selected objects only",
|
description="Export selected objects only",
|
||||||
default=False,
|
default=False,
|
||||||
)
|
)
|
||||||
write_keyframe: BoolProperty(
|
object_filter: EnumProperty(
|
||||||
name="Write Keyframe",
|
name="Object Filter", options={'ENUM_FLAG'},
|
||||||
|
items=(('WORLD', "World".rjust(11), "", 'WORLD_DATA',0x1),
|
||||||
|
('MESH', "Mesh".rjust(11), "", 'MESH_DATA', 0x2),
|
||||||
|
('LIGHT', "Light".rjust(12), "", 'LIGHT_DATA',0x4),
|
||||||
|
('CAMERA', "Camera".rjust(11), "", 'CAMERA_DATA',0x8),
|
||||||
|
('EMPTY', "Empty".rjust(11), "", 'EMPTY_AXIS',0x10),
|
||||||
|
),
|
||||||
|
description="Object types to export",
|
||||||
|
default={'WORLD', 'MESH', 'LIGHT', 'CAMERA', 'EMPTY'},
|
||||||
|
)
|
||||||
|
use_hierarchy: BoolProperty(
|
||||||
|
name="Hierarchy",
|
||||||
|
description="Export hierarchy chunks",
|
||||||
|
default=False,
|
||||||
|
)
|
||||||
|
use_keyframes: BoolProperty(
|
||||||
|
name="Animation",
|
||||||
description="Write the keyframe data",
|
description="Write the keyframe data",
|
||||||
default=False,
|
default=False,
|
||||||
)
|
)
|
||||||
|
use_cursor: BoolProperty(
|
||||||
|
name="Cursor Origin",
|
||||||
|
description="Save the 3D cursor location",
|
||||||
|
default=False,
|
||||||
|
)
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
from . import export_3ds
|
from . import export_3ds
|
||||||
@ -130,6 +264,74 @@ class Export3DS(bpy.types.Operator, ExportHelper):
|
|||||||
|
|
||||||
return export_3ds.save(self, context, **keywords)
|
return export_3ds.save(self, context, **keywords)
|
||||||
|
|
||||||
|
def draw(self, context):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class MAX3DS_PT_export_include(bpy.types.Panel):
|
||||||
|
bl_space_type = 'FILE_BROWSER'
|
||||||
|
bl_region_type = 'TOOL_PROPS'
|
||||||
|
bl_label = "Include"
|
||||||
|
bl_parent_id = "FILE_PT_operator"
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def poll(cls, context):
|
||||||
|
sfile = context.space_data
|
||||||
|
operator = sfile.active_operator
|
||||||
|
|
||||||
|
return operator.bl_idname == "EXPORT_SCENE_OT_max3ds"
|
||||||
|
|
||||||
|
def draw(self, context):
|
||||||
|
layout = self.layout
|
||||||
|
layout.use_property_split = True
|
||||||
|
layout.use_property_decorate = True
|
||||||
|
|
||||||
|
sfile = context.space_data
|
||||||
|
operator = sfile.active_operator
|
||||||
|
|
||||||
|
layrow = layout.row(align=True)
|
||||||
|
layrow.prop(operator, "use_selection")
|
||||||
|
layrow.label(text="", icon='RESTRICT_SELECT_OFF' if operator.use_selection else 'RESTRICT_SELECT_ON')
|
||||||
|
layout.column().prop(operator, "object_filter")
|
||||||
|
layrow = layout.row(align=True)
|
||||||
|
layrow.prop(operator, "use_hierarchy")
|
||||||
|
layrow.label(text="", icon='OUTLINER' if operator.use_hierarchy else 'CON_CHILDOF')
|
||||||
|
layrow = layout.row(align=True)
|
||||||
|
layrow.prop(operator, "use_keyframes")
|
||||||
|
layrow.label(text="", icon='ANIM' if operator.use_keyframes else 'DECORATE_DRIVER')
|
||||||
|
layrow = layout.row(align=True)
|
||||||
|
layrow.prop(operator, "use_cursor")
|
||||||
|
layrow.label(text="", icon='PIVOT_CURSOR' if operator.use_cursor else 'CURSOR')
|
||||||
|
|
||||||
|
|
||||||
|
class MAX3DS_PT_export_transform(bpy.types.Panel):
|
||||||
|
bl_space_type = 'FILE_BROWSER'
|
||||||
|
bl_region_type = 'TOOL_PROPS'
|
||||||
|
bl_label = "Transform"
|
||||||
|
bl_parent_id = "FILE_PT_operator"
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def poll(cls, context):
|
||||||
|
sfile = context.space_data
|
||||||
|
operator = sfile.active_operator
|
||||||
|
|
||||||
|
return operator.bl_idname == "EXPORT_SCENE_OT_max3ds"
|
||||||
|
|
||||||
|
def draw(self, context):
|
||||||
|
layout = self.layout
|
||||||
|
layout.use_property_split = True
|
||||||
|
layout.use_property_decorate = False
|
||||||
|
|
||||||
|
sfile = context.space_data
|
||||||
|
operator = sfile.active_operator
|
||||||
|
|
||||||
|
layout.prop(operator, "scale_factor")
|
||||||
|
layrow = layout.row(align=True)
|
||||||
|
layrow.prop(operator, "use_scene_unit")
|
||||||
|
layrow.label(text="", icon='EMPTY_ARROWS' if operator.use_scene_unit else 'EMPTY_DATA')
|
||||||
|
layout.prop(operator, "axis_forward")
|
||||||
|
layout.prop(operator, "axis_up")
|
||||||
|
|
||||||
|
|
||||||
# Add to a menu
|
# Add to a menu
|
||||||
def menu_func_export(self, context):
|
def menu_func_export(self, context):
|
||||||
@ -142,16 +344,22 @@ def menu_func_import(self, context):
|
|||||||
|
|
||||||
def register():
|
def register():
|
||||||
bpy.utils.register_class(Import3DS)
|
bpy.utils.register_class(Import3DS)
|
||||||
|
bpy.utils.register_class(MAX3DS_PT_import_include)
|
||||||
|
bpy.utils.register_class(MAX3DS_PT_import_transform)
|
||||||
bpy.utils.register_class(Export3DS)
|
bpy.utils.register_class(Export3DS)
|
||||||
|
bpy.utils.register_class(MAX3DS_PT_export_include)
|
||||||
|
bpy.utils.register_class(MAX3DS_PT_export_transform)
|
||||||
bpy.types.TOPBAR_MT_file_import.append(menu_func_import)
|
bpy.types.TOPBAR_MT_file_import.append(menu_func_import)
|
||||||
bpy.types.TOPBAR_MT_file_export.append(menu_func_export)
|
bpy.types.TOPBAR_MT_file_export.append(menu_func_export)
|
||||||
|
|
||||||
|
|
||||||
def unregister():
|
def unregister():
|
||||||
bpy.utils.unregister_class(Import3DS)
|
bpy.utils.unregister_class(Import3DS)
|
||||||
|
bpy.utils.unregister_class(MAX3DS_PT_import_include)
|
||||||
|
bpy.utils.unregister_class(MAX3DS_PT_import_transform)
|
||||||
bpy.utils.unregister_class(Export3DS)
|
bpy.utils.unregister_class(Export3DS)
|
||||||
|
bpy.utils.unregister_class(MAX3DS_PT_export_include)
|
||||||
|
bpy.utils.unregister_class(MAX3DS_PT_export_transform)
|
||||||
bpy.types.TOPBAR_MT_file_import.remove(menu_func_import)
|
bpy.types.TOPBAR_MT_file_import.remove(menu_func_import)
|
||||||
bpy.types.TOPBAR_MT_file_export.remove(menu_func_export)
|
bpy.types.TOPBAR_MT_file_export.remove(menu_func_export)
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user