I am not a programmer and I don't know what I am doing.
I want to export many shapekeys as OBJ files from an active object. Doing this manually would take an insane amount of time. Unfortunately, I haven't found an existing script that is doing this.
What I want to do: (Blender button: I dont know how to do that)
for each 'shapekey' in the 'acive object':
if shapekey is 'hidden'
1. unhide shapekey
2. export 'active object' as "shapekey's name".obj
3. hide shapekey
Updated for Blender 2.8
# Export all 'hidden' shape_keys from all 'hidden' objects in the scene.
# Only ACTIVE 'LAYERS' will export objects.
import os
import bpy
basedir = bpy.path.abspath('//')
for obj in bpy.data.objects:
if obj.hide_get():
if obj.data.shape_keys:
bpy.context.view_layer.objects.active = obj
obj.hide_set(False)
obj.select_set(True)
for k in bpy.context.active_object.data.shape_keys.key_blocks:
if k.mute:
k.mute = False
print(k.name)
bpy.ops.export_scene.obj(
filepath=os.path.join(basedir, k.name + '.obj'),
use_selection=True,
global_scale=1,
axis_forward='-Z',
axis_up='Y',
use_normals=False,
use_materials=False,
keep_vertex_order=True)
k.mute = True
obj.select_set(False)
obj.hide_set(True)