Batch Convert STP to FBX

 From:  ironsightdesign
9695.1 
I've been trying to piece together code for a script to batch convert over 200 .stp files to .fbx, but cant seem to get it working.

These are my scripts (inside a "scripts" folder in the MOI program files directory, called with a shorthcut:

------
BatchConvert.js
// This is the script file that you would generate, put one line in
// for each file you want to convert.

#include "Convert.js"

function ConvertFolder( FolderName, FileExtensionToLoad )
{
// Convert all files within a given folder, that have the given file extension.
// For example, convert all .3dm files inside of the folder c:\test :
// ConvertFolder( 'c:\\test', '3dm' );

ConvertFolder( 'd:\\_convert', 'stp' );

var Files = moi.filesystem.getFiles( FolderName, '*.' + FileExtensionToLoad );

for ( var i = 0; i < Files.length; ++i )
Convert( Files.item(i) );
}


------
Convert.js
function Convert( FileName )
{
var gd = moi.geometryDatabase;

// Open the file, set 2nd param to true to suppress any save changes prompt.
gd.open( FileName, true );

// Create the output file name by breaking off the file extension and adding 'obj'.

FBXFileName = FileName.substr( 0, FileName.lastIndexOf('.') + 1 ) + 'fbx';

// Save out to the output file, passing the option to suppress the UI. You
// add other options separated by semi-colons with no spaces. These
// options are available for controlling the meshing:
// NoUI=true
// Angle=12.0
// Output=ngons | quads | triangles
// MaxLength=0.0
// MaxLengthApplyTo=curved | planes | all
// MinLength=0.0
// AspectRatio=0.0
// Weld=true
// Display=shadedwithedges | shadednoedges | wireframe
// ExpandedDialog=false

gd.saveAs( FBXFileName, 'NoUI=true;Angle=8.0;Weld=true;MaxLength=4;Output=quads' );

// Let's clear out and suppress any save changes prompt again.
gd.fileNew( true );

}


-----

Thanks for any help!