-
-
Save versluis/2e092b466b989b1e91f316599bcce016 to your computer and use it in GitHub Desktop.
# Export all Shape Keys as OBJs in Blender | |
# Version 1.0 - August 2017 | |
# ========================================= | |
# Original Script by Tlousky | |
# https://blender.stackexchange.com/questions/86674/how-to-batch-export-shapekeys-as-obj-from-the-active-object/86678#86678 | |
# with small tweaks by Jay Versluis | |
# https://www.versluis.com | |
import bpy | |
from os.path import join | |
# Reference the active object | |
o = bpy.context.active_object | |
# CHANGE THIS to the folder you want to save your OBJ files in | |
# NOTE: no spaces, no trailing slash | |
exportPath = "/Users/you/somewhere" | |
# Reset all shape keys to 0 (skipping the Basis shape on index 0 | |
for skblock in o.data.shape_keys.key_blocks[1:]: | |
skblock.value = 0 | |
# Iterate over shape key blocks and save each as an OBJ file | |
for skblock in o.data.shape_keys.key_blocks[1:]: | |
skblock.value = 1.0 # Set shape key value to max | |
# Set OBJ file path and Export OBJ | |
objFileName = skblock.name + ".obj" # File name = shapekey name | |
objPath = join( exportPath, objFileName ) | |
bpy.ops.export_scene.obj( filepath = objPath, use_selection = True, global_scale = 1 ) | |
skblock.value = 0 # Reset shape key value to 0 | |
# THE END |
If anybody found the output OBJs are the same as basis model, you can change bpy.ops.export_scene.obj( filepath = objPath, use_selection = True, global_scale = 1 )
to bpy.ops.wm.obj_export(filepath = objPath,export_selected_objects=True,export_uv=True,scaling_factor=1.0,apply_modifiers=True,export_materials=False)
.
Still good to go on Blender 3.3.2
Hi, I tried both versions of the code listed above but the exported objs are still the same as the basis model. I'm currently using Blender 3.3.4. Is there an update to work with this version? Thank you in advance for any info anyone can provide.
Its showing bpy.ops.export_scene.obj error while exporting shapekeys
bpy.ops.wm.obj_export(filepath = objPath,export_selected_objects=True,export_uv=True,scaling_factor=1.0,apply_modifiers=True,export_materials=False)
Thanks! It works. I mean, I get the basic things working. Need to test this with complex UV Maps.
Great! This code still works even in blender 3.0. Awesome.