Batch converting with unit option

Next
 From:  manuel (RBMANUEL)
8127.1 
Hi,

i have a lot of files to convert from step to obj, and they all come in different unit systems.

Now i use the BatchConvert script (see attachment) and i'd like to know if it's possible to add an option to convert the units to centimeters in the beginning?

I've checked the Unit options in Moi (Scale on unit system change and Scale when importing different units) but they don't seem to have any effect on the batch converting.


Thanks

Manuel
Attachments:

  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
8127.2 In reply to 8127.1 
Hi Manuel, unfortunately I don't think it's possible currently to change the unit system from a startup script like that.

The problem is that the object scaling part of a unit system change is run as a "command", so that it will get undo units generated for it when it's done from the UI in the regular way.

But that action is asynchronous, when a command is launched a flag is set and any current actions are canceled, and the command is only run when MoI returns to its idle state. That's to avoid having actions getting nested up. But because you're in the middle of running a script MoI will not be in its idle state and so the scaling will only happen after the script is finished. There isn't currently any way set up for the script to wait for unit system change command to finish.

I could do something to fix this for v4, to make the unit change object scaling happen immediately if it's being called from a startup script, but for v3 I don't think there's a way to make it work like that.

I guess another way that could work is if your script looked at the current unit system ( moi.geometryDatabase.units ) which will be set after opening a file, and change the OBJ export scale factor to the proper conversion value. The OBJ export scale factor can be changed by setting moi.settings.objExportScaleFactor .

So it would be something like this in a function that you'd call before any export (warning, untested):

code:
function UpdateOBJScaleFactor()
{
     var factor = 1.0;

     switch( moi.geometryDatabase.units )
     {
     case 'Meters' : factor = 100.0; break;
      <...>
     }

     moi.settings.objExportScaleFactor = factor;
}



- 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:  manuel (RBMANUEL)
8127.3 In reply to 8127.2 
Hi Michael,

thank you for your help.

I use the MaxLength and MinLength options in the tessellation engine and the results seem to be dependent on the scene unit.

As far as i understand the obj scale factor won't help me in this case.


Thank you again for your efforts.

Manuel
  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
8127.4 In reply to 8127.3 
Hi Manuel,

re:
> I use the MaxLength and MinLength options in the tessellation engine and the
> results seem to be dependent on the scene unit.

Yes that will be an additional complication, but it should still be solvable. I guess you mean you want to apply MaxLength and MinLength always at some specific value in centimeters. In order to do this you will need to have your script look at the current unit system and apply a scale factor to your MaxLength-in-cm value to convert it into the equivalent MaxLength-in-current-units value, and then that's what you set for the meshing parameters.

So note that the scale factor for this part will be cm to current model units, it will be the reciprocal of the one for the obj scale factor which you want to be current model units to cm.


> As far as i understand the obj scale factor won't help me in this case.

Correct, the obj scale factor only helps with transforming the final output. But it should be possible to use the method described above to handle this other problem.

- 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:  manuel (RBMANUEL)
8127.5 In reply to 8127.4 
I'll forward it to our programmer at work.


Thank you very much

Manuel
  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