Maya AbcExport with Python

14,100

Solution 1

You can find help for cmds.AbcExport and cmds.AbcImport by instantiating them with the h arg set to True. The following commands will print help docs:

maya.cmds.AbcExport(h=True)
maya.cmds.AbcImport(h=True)

Solution 2

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)

Solution 3

I found a way to do it indirectly in Python, by using the MEL command :

import maya.mel as mel
cmds.loadPlugin( 'AbcExport.mll' )
cmds.loadPlugin( 'AbcImport.mll' )


mel_cmd = 'AbcExport -j "-frameRange 31 41 -writeVisibility -dataFormat ogawa -root |myChar:char|myChar:GEOchar -file E:/test.abc"'
mel.eval(mel_cmd)
Share:
14,100
Caryluna
Author by

Caryluna

Updated on June 16, 2022

Comments

  • Caryluna
    Caryluna about 2 years

    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!