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
|