Created
August 4, 2025 15:55
-
-
Save NikkosAM/9db70e3394f979a5d6c91ad995385282 to your computer and use it in GitHub Desktop.
Export Mesh with ShapesKeys - Blender 4.5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import bpy | |
| # ——— CONFIGURE THIS ——— | |
| export_path = r"Y:\My Drive\Libraries\Escena Drive\STUDIO\Atrapados\3D\OBJ\Characters\Alex\Eyes\blendshape_export.fbx" | |
| # ———————————————————— | |
| # 1) Get and validate the active object | |
| obj = bpy.context.active_object | |
| if not obj or obj.type != 'MESH': | |
| raise RuntimeError("Please select an active mesh object before exporting.") | |
| # 2) Deselect everything, then select only the target mesh | |
| bpy.ops.object.select_all(action='DESELECT') | |
| obj.select_set(True) | |
| bpy.context.view_layer.objects.active = obj | |
| # 3) Call the FBX exporter with a robust set of options | |
| bpy.ops.export_scene.fbx( | |
| filepath=export_path, # Where to write the file :contentReference[oaicite:6]{index=6} | |
| check_existing=True, # Warn if overwriting :contentReference[oaicite:7]{index=7} | |
| filter_glob="*.fbx", # File browser filter :contentReference[oaicite:8]{index=8} | |
| use_selection=True, # Only export the selected mesh :contentReference[oaicite:9]{index=9} | |
| global_scale=1.0, # Keep 1:1 scale :contentReference[oaicite:10]{index=10} | |
| apply_unit_scale=True, # Apply Blender unit scale :contentReference[oaicite:11]{index=11} | |
| apply_scale_options='FBX_SCALE_NONE', # Use local object transforms only :contentReference[oaicite:12]{index=12} | |
| use_space_transform=True, # Write axis-space transforms :contentReference[oaicite:13]{index=13} | |
| bake_space_transform=False, # Don’t bake transforms into geometry :contentReference[oaicite:14]{index=14} | |
| object_types={'MESH'}, # Export only mesh objects :contentReference[oaicite:15]{index=15} | |
| use_mesh_modifiers=True, # Apply modifiers before export :contentReference[oaicite:16]{index=16} | |
| use_mesh_modifiers_render=True, # Use render‐time modifier settings :contentReference[oaicite:17]{index=17} | |
| mesh_smooth_type='OFF', # No auto‐smoothing :contentReference[oaicite:18]{index=18} | |
| use_custom_props=False, # Don’t include custom Blender props :contentReference[oaicite:19]{index=19} | |
| add_leaf_bones=False, # Suppress extra leaf bones :contentReference[oaicite:20]{index=20} | |
| bake_anim=True, # Bake all animations (incl. Shape Key keys) :contentReference[oaicite:21]{index=21} | |
| bake_anim_use_all_actions=True, # Export every action as FBX clips :contentReference[oaicite:22]{index=22} | |
| bake_anim_force_startend_keying=True, # Force keys at start/end :contentReference[oaicite:23]{index=23} | |
| path_mode='AUTO', # Embed textures & automatically manage paths :contentReference[oaicite:24]{index=24} | |
| axis_forward='-Z', # Match Blender’s FBX forward axis :contentReference[oaicite:25]{index=25} | |
| axis_up='Y' # Match Blender’s FBX up axis :contentReference[oaicite:26]{index=26} | |
| ) | |
| print(f"✅ Exported '{obj.name}' with all Shape Keys to:\n {export_path}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment