Maya: Exporting out Collada files

I am trying to make an exporter that saves out a scene hierarchy and exports the meshes in a scene as separate collada files. Yes, I know: Collada is crap - but the engine only takes this format I am afraid.

I’ve worked with FBX exporters before so I know the drill for exporting out objects.
But when it comes to the Collada format I am confused. I’ve tried both the file -command (with the type flag set to “DAE_FBX export”) and I’ve also tried the FBXExport -command and neither seem to spit out any DAE files for me.

Using pymel.core.FBX* (pymel.core.other.FBX*** in PyMEL 1.7 and earlier)**

pm.mel.FBXResetExport() # Then I run a couple of commands to setup the settings for the FBX plugin, like: pm.mel.FBXExportFileVersion(v="FBX201600") pm.mel.FBXExportColladaTriangulate(True) pm.mel.FBXExport( s=True, # selection f=export_path, # fullPath - directory, file name and type specified, ex c:\dolan\duk.dae caller="FBXDAEMayaTranslator" # Makes the damn dialog appear )No files output. Batch export gets stuck because the dialog appears and Maya then complains about “the dialog is already open”. But even if I export a single primitive, no file is generated. The only collada-related FBX -commands I find are:

FBXExportColladaFrameRate
FBXExportColladaSingleMatrix
FBXExportColladaTriangulate

Using pymel.core.cmds.file

options_string = "model=1;animation=0;material=0;optimisegeometry=1;normals=1;tangents=1;colorformat=2;colorsets=;uvsets=$map1$;" pm.cmds.file( force=True, options=options_string, type="DAE_FBX export", preserveReferences=True, exportSelected=True, )Does not work nor does it generate any errors. The only thing that happens is that some warning pops up in the “Warnings and Errors” -dialog:
“Warning: ‘Null’ type not supported by COLLADA. Only the transform data of node: ‘cylinder_grp’ will be saved.”

Not sure how to progress here as the FBX documentation is utter crap…

CLUE:
The wrong dialog appears. It’s not the options dialog for the Collada format that appears but the usual FBX options dialog. This happens both with the pymel.core.FBXExport() -case and the pymel.core.cmds.file() -case.

So this works for me with just a sphere selected.

cmds.file('%userprofile%/test.dae', type='DAE_FBX export', pr=True, force=True, exportSelected=True)

From what I understand the DAE_FBX exporter will open up the usual FBX export dialog, it just happens to included the collada section. I don’t believe any of the FBX options actually do anything, at least they did not change the options being passed to the file command.

If you need a more robust exporter you should probably look at the OpenCollada exporters available for max and maya. It’s been nearly a decade since I had to use these, so I can’t directly comment on easy of use.

Thanks for the reply.
I got it working with pm.mel.FBXExport()
I noticed that I had forgotten to specify the file name +extension for the fullPath -flag. Strangely enough the FBX plugin gives you NO warnings, errors or complains about it - it just silently refuse to output anything for you (isn’t that awesome)! So I added the file name and I was able to export the objects. However they default to the FBX format (also silently). You have to explicitly provide the .dae -file extension in the path. Once that has been done, Maya will export out the files as dae.

Awesome, glad you got it sorted.

Odd that it wasn’t throwing any errors though, but then again, even the errors I was getting weren’t exactly useful.