Exporting an FBX from python

MakeHuman python API, python plugins, etc

Moderator: joepal

Exporting an FBX from python

Postby rambutan2000 » Thu May 18, 2017 9:38 pm

Hi all, just getting started with MakeHuman python APIs.

I'm trying to export the current human model to an fbx to a given filename. Nothing special just exactly what you can do in the GUI.

I've found 9_export_fbx module but I assume you'd have to call this from some other API.

Any help would be greatly appreciated!

TNKS!
rambutan2000
 
Posts: 2
Joined: Thu May 18, 2017 9:34 pm

Re: Exporting an FBX from python

Postby rambutan2000 » Thu May 18, 2017 11:51 pm

Got it working from the scripting panel:

Code: Select all
import os

# Export file path
path = u'D:\\Temp4\\test\\test.fbx'
dir, name = os.path.split(path)
name, ext = os.path.splitext(name)

# Getting current export path so we can reset it later
curExportdir = G.app.getSetting('exportdir')

G.app.setSetting('exportdir', dir)

# Can't just pass an exporter a path, must give it a validation function
def filename(targetExt, different = False):
   global name, dir
   if  targetExt.lower() != 'fbx':
      log.warning("expected extension '.%s' but got '%s'", targetExt,  'fbx')
   return  os.path.join(dir, name + '.' + targetExt)

# Getting human to export
human = G.app.selectedHuman

# Getting exporter and exporting fbx
exporter = G.app.getCategory('Files').getTaskByName('Export').getExporter('Filmbox (fbx)')
exporter.export(human, filename)

# Resetting exportdir
G.app.setSetting('exportdir', curExportdir)
rambutan2000
 
Posts: 2
Joined: Thu May 18, 2017 9:34 pm


Return to Python scripts

Who is online

Users browsing this forum: No registered users and 1 guest