Update export, to be more clear and readable.

This commit is contained in:
2024-05-31 10:42:41 +02:00
parent d20a7d2198
commit 940bc14d77
+63 -69
View File
@@ -27,7 +27,6 @@ Requiert your blend file are write on your hard-drive."""
def execute(self, context): def execute(self, context):
bpy.ops.object.select_all(action='DESELECT') bpy.ops.object.select_all(action='DESELECT')
print(f'[Pipeline] Start to export the building props.')
# Make a check if the file are saved on the disk # Make a check if the file are saved on the disk
if not bpy.data.is_saved: if not bpy.data.is_saved:
@@ -42,81 +41,76 @@ Requiert your blend file are write on your hard-drive."""
self.report({'WARNING'}, 'No children collection, nothing can be exported.') self.report({'WARNING'}, 'No children collection, nothing can be exported.')
return {'CANCELLED'} return {'CANCELLED'}
if not len(self.coll_layout.collection_children): for coll in self.coll_layout.children:
print(f'[Pipeline] Update "{coll.name}" mesh')
child = bpy.data.collections.get(coll.name)
for coll in self.coll_layout.children: for ob in child.all_objects:
print(f'[Pipeline] Update "{coll.name}" mesh') print(f'\tLook "{ob.name}", his type are "{type(ob.data)}"')
child = bpy.data.collections.get(coll.name) # TODO Support another type object, not only SM/SK
if ob.type == 'MESH' or 'EMPTY':
print(f'[Pipeline] Check ob {ob.name} and is type {type(ob)}')
ob.select_set(True)
for ob in child.all_objects: if ob.type == 'EMPTY':
print(f'\tLook "{ob.name}", his type are "{type(ob.data)}"') if ob.instance_type != 'NONE':
# TODO Support another type object, not only SM/SK self.instance_type_dict[ob.name] = ob.instance_type
if ob.type == 'MESH' or 'EMPTY': ob.instance_type = 'NONE'
print(f'[Pipeline] Check ob {ob.name} and is type {type(ob)}')
ob.select_set(True)
if ob.type == 'EMPTY': abs_export = self.category.joinpath(self.asset, "Meshes")
if ob.instance_type != 'NONE': if not abs_export.exists():
self.instance_type_dict[ob.name] = ob.instance_type abs_export.mkdir(parents=True)
ob.instance_type = 'NONE'
abs_export = self.category.joinpath(self.asset, "Meshes") if coll.name != 'Socket':
if not abs_export.exists(): asset_name = f"SM_{coll.name}.fbx"
abs_export.mkdir(parents=True) else:
asset_name = f"{coll.name}.fbx"
if coll.name != 'Socket': # TODO Use the preset system
asset_name = f"SM_{coll.name}.fbx" bpy.ops.export_scene.fbx(filepath=abs_export.joinpath(asset_name).as_posix(),
else: use_selection=True,
asset_name = f"{coll.name}.fbx" use_visible=False,
use_active_collection=False,
global_scale=1.0,
apply_unit_scale=True,
apply_scale_options='FBX_SCALE_NONE',
use_space_transform=True,
bake_space_transform=True,
object_types={'MESH', 'EMPTY'},
use_mesh_modifiers=True,
use_mesh_modifiers_render=True,
mesh_smooth_type='OFF',
colors_type='SRGB',
prioritize_active_color=False,
use_subsurf=False,
use_mesh_edges=False,
use_tspace=False,
use_triangles=False,
use_custom_props=False,
add_leaf_bones=True,
primary_bone_axis='Y',
secondary_bone_axis='X',
use_armature_deform_only=False,
armature_nodetype='NULL',
bake_anim=False,
bake_anim_use_all_bones=True,
bake_anim_use_nla_strips=True,
bake_anim_use_all_actions=True,
bake_anim_force_startend_keying=True,
bake_anim_step=1.0,
bake_anim_simplify_factor=1.0,
path_mode='AUTO',
embed_textures=False,
batch_mode='OFF',
use_batch_own_dir=True,
axis_forward='X',
axis_up='Y'
)
# TODO Use the preset system print(f'[Pipeline] Export here "{abs_export}"')
bpy.ops.export_scene.fbx(filepath=abs_export.joinpath(asset_name).as_posix(), bpy.ops.object.select_all(action='DESELECT')
use_selection=True,
use_visible=False,
use_active_collection=False,
global_scale=1.0,
apply_unit_scale=True,
apply_scale_options='FBX_SCALE_NONE',
use_space_transform=True,
bake_space_transform=True,
object_types={'MESH', 'EMPTY'},
use_mesh_modifiers=True,
use_mesh_modifiers_render=True,
mesh_smooth_type='OFF',
colors_type='SRGB',
prioritize_active_color=False,
use_subsurf=False,
use_mesh_edges=False,
use_tspace=False,
use_triangles=False,
use_custom_props=False,
add_leaf_bones=True,
primary_bone_axis='Y',
secondary_bone_axis='X',
use_armature_deform_only=False,
armature_nodetype='NULL',
bake_anim=False,
bake_anim_use_all_bones=True,
bake_anim_use_nla_strips=True,
bake_anim_use_all_actions=True,
bake_anim_force_startend_keying=True,
bake_anim_step=1.0,
bake_anim_simplify_factor=1.0,
path_mode='AUTO',
embed_textures=False,
batch_mode='OFF',
use_batch_own_dir=True,
axis_forward='X',
axis_up='Y'
)
print(f'[Pipeline] Export here "{abs_export}"') self.set_instance_type()
bpy.ops.object.select_all(action='DESELECT')
self.set_instance_type()
# for coll in coll_layout.children:
# print(f'[Pipeline] Check {coll}. Item type {type(coll)}')
self.report({'INFO'}, 'Placeholder exported') self.report({'INFO'}, 'Placeholder exported')
return {'FINISHED'} return {'FINISHED'}