Start a new topic

Quick obj import export 2 flt script

I was looking to repurpose a script that i have for flt to fbx export.  But I just need a quick script to open/import .objs from a folder and just save them as a .flt with the same name.

actually the files are .dae needing to be imported and saved to flt

Hi, it is pretty simple to script this up. The following line will import the dae file to the database. Just change the filename and path to the one you want, or prompt the user to enter etc...

mgImportDb (db, 'c:\\temp\\box.dae', 'D5637D1C-F499-4726-8CF9-333C68F68D8E', None) 

An interesting node, for this particular importer, you can just change the extension from .dae to .obj and it will use the fbx implementation of obj import. (the FBX format key 'D5637D1C-F499-4726-8CF9-333C68F68D8E' works for fbx, obj and dae import.)

 All that needs to be done is to open a new database, call the mgImportDb, the mgWriteDb and mgCloseDb

db = mgNewDb ('c:\\temp\\newDb.flt')
mgImportDb (db, 'c:\\temp\\box.dae', 'D5637D1C-F499-4726-8CF9-333C68F68D8E', None)


Some times, the models are the wrong scale depending on how much scale and axis information is in the files. Here is an example of how to manually correct the axis in case the z and y up are an issue: You might have to correct the scale to by adding a scale transform.

db = mgGetCurrentDb()

g1 = mgGetChild(db)
mgSetModelingParent (db, g1)

mgImportDb (db, 'c:\\temp\\box.dae', 'D5637D1C-F499-4726-8CF9-333C68F68D8E', None)

xform = mgNewRec(fltXmRotateEdge)
mgSetCoord3d (xform, fltXmRotRefPoint1, 0, 0, 0)
mgSetCoord3d (xform, fltXmRotRefPoint2, 1, 0, 0)
mgSetAttList (xform, fltXmRotEdgeAngle, 90)

mgAttach(g1, xform)


Login to post a comment