Maya animation to Blender script

Hi,

I’m actually working on a studio and for my job, I need to create Smoke and used Blender.

So I’ve created this small script that export *.obj sequences from Maya, and then import it to Blender :

For productivity reason, I didn’t take time to make an interface (maybe next time).

You’ll need to paste this script to Maya script editor and change the first 3 variables :
Note : do not write .obj after the file name


int $startFrame = 1;
int $endFrame = 24;
//Linux user
string $file = "/home/you/folder/file"
//Windows user (uncomment the next row and comment the previous one)
//string $file = "C:\\your\\folder\\file"

for ($i=$startFrame; $i <= $endFrame; ++$i)
{
	currentTime $i;
	file -op "groups=1;ptgroups=1;materials=0;smoothing=1;normals=1" -typ "OBJexport" -pr -es ($file + $i);
}

Then in Blender 2.5 (do not work with 2.4 and before), paste the next script in the text editor, change the first 3 variables and Run Script
(same variable and do not write .obj after file name)

Note : Create a new file to import you obj sequence is safer.


import bpy

startFrame = 1;
endFrame = 24;

#Linux
file = "/home/you/folder/file"
#Windows
#file        = "C:\\your\\folder\\file"



    
i           = startFrame
    
bpy.ops.import_scene.obj(filepath=(file + str(i) + ".obj"))

bpy.ops.object.select_all(action='DESELECT')
bpy.ops.object.select_name(name="Mesh")

bpy.ops.object.shape_key_add()

i1          = 1
while i <= endFrame:
    bpy.ops.import_scene.obj(filepath=(file + str(i) + ".obj"))
    
    bpy.ops.object.select_all(action='DESELECT')
    bpy.ops.object.select_name(name="Mesh.001")
    bpy.ops.object.select_name(name="Mesh")
    
    bpy.ops.object.join_shapes()
    
    bpy.data.objects["Mesh"].data.shape_keys.keys[i1].value = 0.0
    bpy.data.objects["Mesh"].data.shape_keys.keys[i1].keyframe_insert("value", frame=(i-1))
    bpy.data.objects["Mesh"].data.shape_keys.keys[i1].value = 1.0
    bpy.data.objects["Mesh"].data.shape_keys.keys[i1].keyframe_insert("value", frame=(i))
    bpy.data.objects["Mesh"].data.shape_keys.keys[i1].value = 0.0
    bpy.data.objects["Mesh"].data.shape_keys.keys[i1].keyframe_insert("value", frame=(i+1))
    
    bpy.ops.object.select_all(action='DESELECT')
    bpy.ops.object.select_name(name="Mesh.001")
    bpy.ops.object.delete()
    
    i += 1
    i1 += 1
    
bpy.data.objects["Mesh"].data.shape_keys.keys[i1 - 1].value = 1.0
bpy.data.objects["Mesh"].data.shape_keys.keys[i1 - 1].keyframe_insert("value", frame=(i))
  • :eyebrowlift:

this may be of interest to you : http://www.pasteall.org/17587/python
it’s a .ma importer i am working on (on and off) supports cameras, emptys and basic animation atm.