Maya AbcExport with Python

Caryluna picture Caryluna · Apr 25, 2017 · Viewed 10.4k times · Source

I have the script to export an Alembic from Maya with MEL :

AbcExport(-frameRange 31 41 -writeVisibility -dataFormat ogawa -root |myChar:char|myChar:GEOchar -file E:/test.abc)

I would like to do the same with Python. Something like :

cmds.AbcExport(...)

I can't find any documentation about it... Any idea?

Thank you a lot!

Answer

beisbeis picture beisbeis · May 2, 2017

You can run this command on Python using the jobArg flag:

import maya.cmds as cmd

start = 0
end = 120
root = "-root pSphere1 -root pCube1"
save_name = "c:\documents\maya\project\default\cache\alembicTest.abc"

command = "-frameRange " + start + " " + end +" -uvWrite -worldSpace " + root + " -file " + save_name
cmd.AbcExport ( j = command )

Just tested this with Maya 2016.5, and it works for me.

Like you, I could not find any official documentation showing this, only unofficial sources like these:

http://www.wenie.net/notes/alembic-cache-script-via-python (where I found the example code)

http://forums.cgsociety.org/archive/index.php?t-1156807.html (the python format is used on the bottom post, which means this exists back to Maya 2015, if one is still using it)