Also, if you like diving into the code of someone else, you can try to look at the MESA importer/exporter. This is for source content, but this should help you to know how the breakdown of the Maya meshes is done before exporting. For the obj format, I know a python version, not mel : http://www.hodge.net.au/sam/blog/?p=250