Automating conversion of IGES files to OBJ files

 From:  Michael Gibson
987.8 In reply to 987.7 
Hi Al, ok the new patch that enables this batch processing is now ready, link is here: http://moi3d.com/forum/index.php?webtag=MOI&msg=1013.1

It now does auto join surfaces from IGES files together, that is generally a good idea since you do get the common mesh structure along the shared edges to avoid cracks. You can turn it off if you want with the .ini flag mentioned in the link above, or through script by: moi.settings.igesJoinOnImport = false;

The first step is that you can pass the name of a script file as a command-line parameter to MoI.exe . If there are any spaces in the script file name, the entire file name should be enclosed in double quotes, like:
MoI.exe "c:\path with spaces\script.js"

You should be able to use either a JScript file or a VBScript file (.vbs), but I have only tested JScript.

The script will execute immediately before the main window is displayed, so if your script decides to exit MoI the actual MoI UI will never show up on the screen.

I have attached an example to get you started.

There are 2 files attached - BatchConvert.js, and Convert.js

BatchConvert.js is the file that you would overwrite with your own script, before launching MoI.exe . You just add in one line for a call to Convert() for each IGES file you want to convert to an OBJ.

The Convert() function is defined in the Convert.js library file which is included into BatchConvert.js .

Convert() handles the basic calls into MoI to open and save the files. There are some comments in there about how to control the meshing parameters, this is done by an option string you can pass to the saveAs() function. If you pass NoUI=true, the mesh dialog will not be displayed.

I think that pretty much handles what you were requesting. Please let me know if you have any questions or run into any problems while setting it up.

- Michael

 

EDIT: updated attached file with fixed up Convert.js file from later in the thread that fixes the bug with handling 4-letter extensions like .iges instead of .igs

EDIT2: updated attached file with new function for converting all files within a folder.
http://moi3d.com/forum/index.php?webtag=MOI&msg=2100.5

EDIT3: for a version that will work on the Mac too see here:
http://moi3d.com/forum/index.php?webtag=MOI&msg=6689.2

EDITED: 12 May 2014 by MICHAEL GIBSON

Attachments: