Batch file conversion
 1-3  4-23  24-43  44-48
Thread Split: Some posts in this thread were moved from here

Previous
Next
 From:  Michael Gibson
2100.44 In reply to 2100.43 
Hi Micha, yup this is exactly the kind of thing that would be possible to hand off to other programmers to finish for me if I had some other programmers working for me.

Because I don't have that, I have to be pretty careful about working on things that have a combination of relatively time consuming but not high value general overall return.

There can be some hidden (sometimes very well hidden...) benefits to having limited resources though, since it can force greater precision and help to avoid feature bloat.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  naxos
2100.45 
Hello guys,

I'm trying to convert all igs files in a folder into fbx format...

So i've downloaded the last pack i've found, from Michael...

I've changed the BatchConvert.js to start ConvertFolder( 'c:\\test', 'igs' );
and i've changed 'obj' to 'fbx' into Convert.js...

When i start the cmd, i get a script error :
ReferenceError : Can't find variable : Enumerator... line 46...


here are my scripts :

---------------------
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"

//Convert( 'v:\\Oskab\\convert\\Angle haut 700 x 600.igs' );
//Convert( 'v:\\Oskab\\convert\\Angle haut 924 x 600.igs' );
//Convert( 'v:\\Oskab\\convert\\AR9 P Arr 696 x 376 x 3.igs' );

ConvertFolder( 'v:\\Oskab\\convert', 'igs' );

moi.exit( true ); // Pass true to suppress save changes prompt.


---------------------
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 'fbx'.
var 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:
// (note: | denotes mutually exclusive options, for example for Output choose one
// of the given options, like Output=quads)
//
// 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' );

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

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' );

// Create the FileSystemObject to get access to files and folders.
var FSO = new ActiveXObject( 'Scripting.FileSystemObject' );
var Files = FSO.GetFolder( FolderName ).Files;

// Go through every file in the folder.
for ( var FilesEnum = new Enumerator(Files); !FilesEnum.atEnd(); FilesEnum.moveNext() )
{
var File = FilesEnum.item();
var FileName = File.Path;
var FileExtension = FSO.GetExtensionName( FileName );

// If the extension matches the kind we are converting, call Convert() on it.
if ( FileExtensionToLoad.toLowerCase() == FileExtension.toLowerCase() )
Convert( FileName )
}
}
---------------------

Michael?... some help ?... thanks in advance...
Image Attachments:
Size: 35.6 KB, Downloaded: 30 times, Dimensions: 458x350px
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
2100.46 In reply to 2100.45 
Hi naxos - it looks like that script is using some stuff specific to the Microsoft Jscript implementation which MoI used to use for scripting in MoI v1 and v2.

V3 has switched to use a different script engine and so that one particular area of the script will need to be altered. I'll take a look at that.

But also if you just use MoI v2 instead that same script should work now I think, so that's another solution.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
2100.47 In reply to 2100.45 
Hi naxos, this will require an update to MoI in order to get this script to work in MoI v3 - the script happened to be using a Microsoft-scripting specific mechanism for going through the files within a directory. I'll need to make a built-in method in MoI to handle that part (and the script will need modification to use the new method) since the new script engine in v3 is not able to interface directly with that previous library that the script was trying to use.

So for the next v3 beta there will be a solution for v3 but for the moment to get this script to work you will need to use MoI v2 instead.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  Michael Gibson
2100.48 In reply to 2100.45 
Hi naxos, I've added a new script method for the next v3 beta so that this will be able to work in v3.
With the next beta you'll be able to use this for the ConvertFolder() function inside the Convert.js file:
code:
    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' );
    
        var Files = moi.filesystem.getFiles( FolderName, '*.' + FileExtensionToLoad );
   
        for ( var i = 0; i < Files.length; ++i )
            Convert( Files.item(i) );
    }

But until the next v3 beta is out you'll need to use that version you've already got but with MoI version 2 instead of MoI version 3.

Thanks for reporting the problem so I could get v3 tuned up.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All

 

 
 
Show messages:  1-3  4-23  24-43  44-48