Sunday, September 2, 2012

Softimage: Batch FBX importer

I needed to import a large number of FBX files at once into a scene, then move objects of a specific prefix to zero origin. So made this little script.

#FBX Batch file importer
app = Application

counter = 0

#ask for the path or use default
defaultPath = ('D:\\Projects\\Creaky\\Doomy\\DoomAvModels\\swords\\')
importPath = XSIUIToolkit.PickFolder(defaultPath, 'FBX Batch Load')
#collect the path and find all FBX files in it
if (importPath != ""):
fbxDir  = app.FindFilesInFolder(importPath, ".*\.FBX", True, True)

#import the files individually and prepare them
for f in (fbxDir):
app.FBXImport(f, 0)
app.logMessage ("%s imported"%f)
  counter = counter + 1
app.logMessage('Import Cancelled')

#set all objects to zero origin
objName = app.XSIInputBox('prefix name of items \n to set origin to zero', 'Item Prefix', 'Sword')
wildcard = (objName + '*')

if (objName != ""):
app.logMessage('Called %s'%wildcard)
objSelect = app.selectObj(wildcard)
app.translate(objSelect,0,0,0, 'siAbsolute')
app.logMessage('name doesn\'t exist')

app.logMessage ('%s files imported from %s'%(counter,defaultPath))

If you wish to use this, be aware that you use it at your own risk. Also you may want to change the default path on the 5th line.

1 comment:

Vivian Richard said...

That is some inspirational stuff. Never knew that opinions could be this varied. Thanks for all the enthusiasm to offer such helpful information here.
App Development Company