More stuff

This commit is contained in:
raccoon
2025-01-28 07:02:01 +05:00
parent 0f37a5a02c
commit 8f6a83b86f
2 changed files with 84 additions and 73 deletions

View File

@@ -40,73 +40,69 @@ def fbx_export(context: Context) -> None:
"""
print("[%s] Batch FBX export begin" % datetime.now())
def exporter_ascii(context: Context, filepath: str):
bpy.ops.export_scene.fbx(
context,
version='ASCII6100',
use_selection=True,
global_scale=1.0,
axis_forward='-Z',
axis_up='Y',
object_types=context.scene.fbx_object_types,
use_mesh_modifiers=True,
mesh_smooth_type='OFF',
use_mesh_edges=False,
use_tspace=False,
use_armature_deform_only=False,
add_leaf_bones=False,
primary_bone_axis='Y',
secondary_bone_axis='X',
armature_nodetype='NULL',
use_anim=True,
use_default_take=False,
path_mode='RELATIVE',
batch_mode='OFF',
use_batch_own_dir=False,
filepath=filepath,
)
settings_ascii = dict(
version='ASCII6100',
use_selection=True,
global_scale=1.0,
axis_forward='-Z',
axis_up='Y',
object_types=context.scene.fbx_object_types,
use_mesh_modifiers=True,
mesh_smooth_type='OFF',
use_mesh_edges=False,
use_tspace=False,
use_armature_deform_only=False,
add_leaf_bones=False,
primary_bone_axis='Y',
secondary_bone_axis='X',
armature_nodetype='NULL',
use_anim=context.scene.fbx_use_anim,
use_default_take=False,
path_mode='RELATIVE',
batch_mode='OFF',
use_batch_own_dir=False,
)
def exporter_binary(context: Context, filepath: str):
bpy.ops.export_scene.fbx(
context,
# Common
version = 'BIN7400',
axis_forward = '-Z',
axis_up = 'Y',
apply_scale_options = 'FBX_SCALE_ALL',
apply_unit_scale = True,
bake_space_transform = True,
global_scale = 1.0,
object_types = context.scene.fbx_object_types,
use_custom_props = False,
use_selection = True,
# Mesh
mesh_smooth_type = 'FACE',
use_mesh_modifiers = False,
use_mesh_edges = False,
use_tspace = False,
# Armature
add_leaf_bones = False,
primary_bone_axis = 'Y',
secondary_bone_axis = 'X',
use_armature_deform_only = False,
armature_nodetype = 'NULL',
# Animation
bake_anim = False,
bake_anim_use_all_bones = True,
bake_anim_use_all_actions = True,
bake_anim_use_nla_strips = True,
bake_anim_force_startend_keying = True,
bake_anim_step = 1.0,
bake_anim_simplify_factor = 1.0,
# File
filepath=filepath,
path_mode = 'RELATIVE',
embed_textures = False,
batch_mode = 'OFF',
)
settings_binary = dict(
# Common
version='BIN7400',
axis_forward='-Z',
axis_up='Y',
apply_scale_options='FBX_SCALE_ALL',
apply_unit_scale=True,
bake_space_transform=True,
global_scale=1.0,
object_types=context.scene.fbx_object_types,
use_custom_props=False,
use_selection=True,
# Mesh
mesh_smooth_type='FACE',
use_mesh_modifiers=False,
use_mesh_edges=False,
use_tspace=False,
# Armature
add_leaf_bones=False,
primary_bone_axis='Y',
secondary_bone_axis='X',
use_armature_deform_only=False,
armature_nodetype='NULL',
# Animation
bake_anim=context.scene.fbx_use_anim,
bake_anim_use_all_bones=True,
bake_anim_use_all_actions=True,
bake_anim_use_nla_strips=True,
bake_anim_force_startend_keying=True,
bake_anim_step=1.0,
bake_anim_simplify_factor=1.0,
# File
path_mode='RELATIVE',
embed_textures=False,
batch_mode='OFF',
)
exporter = exporter_binary if _FUTURE else exporter_ascii
settings = settings_binary if _FUTURE or context.scene.fbx_force_binary else settings_ascii
if _FUTURE:
settings.pop('version')
rootpath = os.path.normpath(bpy.path.abspath(context.scene.fbx_export_dir))
groups = bpy.data.collections if _FUTURE else bpy.data.groups
override = context.copy()
@@ -123,8 +119,13 @@ def fbx_export(context: Context) -> None:
"selected_objects": group.objects
}
)
settings.update(
{
"filepath": filepath
}
)
exporter(override, filepath)
bpy.ops.export_scene.fbx(override, **settings)
print("\n[%s] Batch FBX export end." % datetime.now())
@@ -174,10 +175,15 @@ class SCENE_PT_fbx_autoexport(Panel):
col.separator()
sub = col.row()
sub.alignment = 'CENTER'
sub.prop(scene, "fbx_on_save")
sub.prop(scene, "fbx_force_binary")
if _FUTURE:
col.use_property_split = True
col.use_property_decorate = False
col.prop(scene, "fbx_on_save")
col.prop(scene, "fbx_use_anim")
if not _FUTURE:
col.prop(scene, "fbx_force_binary")
col.separator()
col.prop(scene, "fbx_export_dir")
col.operator(FBX_OT_ManualExport.bl_idname)
@@ -233,10 +239,15 @@ def register() -> None:
)
Scene.fbx_group_index = IntProperty(default=0)
Scene.fbx_force_binary = BoolProperty(
name="Binary format",
name="Binary Format",
description="Force export FBX file as binary",
default=False
)
Scene.fbx_use_anim = BoolProperty(
name="Include Animation",
description="Export baked keyframe animation",
default=False
)
Group.fbx_exportable = BoolProperty(
name="Export Group",
description="Mark group as FBX exportable",