Export an FBX from Maya using Python

Posted by:

There are a fair amount of people out there who have weighed in on how to do this in various forums but I didn’t find a single one that actually worked despite them being voted as the solution. Perhaps they worked in previous versions of Maya. I don’t know, but I got this solution by sure educated guess, trial and error. This works as of Maya 2018:

  1. def exportMeshes(*args):
  2. nameField = cmds.textField(shipNameTextField, editable = True, query = True, text=True)
  3. projectDirectory = cmds.workspace(query = True, directory = True)
  4. print('The projectDirectory is: ' + str(projectDirectory))
  5. savePath = str(projectDirectory) + nameField
  6. cmds.sysFile(savePath, makeDir = True)
  7. cmds.file(savePath, exportSelected = True, type = 'FBX')

The code above creates a new folder in your project named by a text field in a form. I didn’t include the form. If you need to know how to build a form and query a textfield just search on my site for textfield and you will find info on how to do that. Cheers!

  Related Posts
  • No related posts found.

You must be logged in to post a comment.