MoI discussion forum
MoI discussion forum

Full Version: MoI file to Blender > MoI

From: mat10x
1 Jul 2019   [#1]
Hi guys,

Trying to incorporate Blender into my workflow with MoI. Been reading up on how to prep a file from MoI V4b to Blender 2.80, and/or Blender to MoI.

Saw threads on this topic all the way back 10 years or so...saw issues with normals, scaling, needing an import script for Blender (LWO file), etc. I seem to be able to import an OBJ from MoI to Blender...but not from Blender to MoI.

Is there some up-to-date resource on this process? A "best practices" sticky somewhere?

Thx.

M
From: Michael Gibson
1 Jul 2019   [#2] In reply to [#1]
Hi mat, I don't think there is a resource page that's up to date for that but yes at some point Blender improved it's OBJ importer quite a bit and so you can just use its standard OBJ importer rather than installing any custom import plugin anymore.

For going from Blender into MoI, that's normal that you would not be able to do that since Blender will be exporting a polygon mesh file and MoI works with NURBS surface data and not polygon data. So normally once you are working with polygon data you won't be importing that data back into MoI.

The exception is that if you are working with sub-d smoothed polygon objects. In that case there is a new importer in V4 that you can use to import it and it will convert it to NURBS surfaces. You can find that on the MoI side pane under SubD > Create > "From file".

But if you have a file that you expect should work going from Blender into MoI can you please post it here so I can take a look?

- Michael
From: mat10x
2 Jul 2019   [#3] In reply to [#2]
Hi Michael,

Exporting OBJ from MoI V4b to Blender 2.80 works great...and the "create > SubD" button to re-import into back to MoI in Nurbs, awesome. Even keeps the model scale back and forth, perfect.

However...OJB created in Blender to MoI...loses the original quads with the "create > SubD" button...but keeps the quads with the MoI V4 "ImpObj" button/script. However, the scale size is different.

1. Box 1 file - OBJ created in Moi V4b > Blender > Moi V4b.
- Retains 15.0mm x 8.0mm x 12.0mm measurement with "Create>SubD" button between both programs.
- MoI "ImpObj" custom UI bottom button import measurement is 30.0mm x 24.0mm x 16.0mm.

2. Box 2 file - OBJ created in Blender 2.8 > Moi V4b.
- Blender measurement was 5.0mm x 3.0mm x 3.0mm.
- MoI V4b "Create > SubD" button...MoI OBJ import size is 0.005mm x 0.003mm x 0.003mm...and loses quads.
- MoI V4b "ImpObj" button is 30.0mm x 18.0mm x 18.0mm...keeps quads but different scale.

OBJs attached.

Thx!

M

Attachments:
Box_1_subD_test.3dm
Box_1_subD_test.obj
Box_2_subD_test.obj

Image Attachments:
Blender_origin_measurement.png  Blender_to_MoI_Create_SubD.png  Blender_to_MoI_ImpObj.png 


From: Michael Gibson
2 Jul 2019   [#4] In reply to [#3]
Hi mat,

re:
> However...OJB created in Blender to MoI...loses the original quads with the "create > SubD" button...

Yes, that's a feature of the SubD importer that it combines patches to make larger surfaces where possible.


> but keeps the quads with the MoI V4 "ImpObj" button/script. However, the scale size is different.

The scale size is also a feature of how Max's ImportOBJ script works by default. But there is an option you can use to change that and maintain the original size, see here:
http://moi3d.com/forum/index.php?webtag=MOI&msg=6674.453

- Michael
From: mat10x
2 Jul 2019   [#5] In reply to [#4]
Hi Michael,

> Yes, that's a feature of the SubD importer that it combines patches to make larger surfaces where possible.

Ah I see how it works now with an actual model part. Yeah big difference, much better without hundreds of quads. Very cool.

So how do I get the "SubD > create > from file" to import at the same scale and X/Y/Z position as the Blender created OBJ? I was able to scale it up by just changing the decimal place but...is there an automatic way to do it?

I looked at the Import/Export options in MoI "OBJ options"...scale factor is at "1". I'm assuming that means 1:1 scale? Blender test model is 430.0mm wide...but imports to MoI at 0.43mm.

> Max's ImportOBJ script
Tried Max's "exact" trick..."_ImportOBJ exact.htm" and "_ImportOBJ exact.js" Command files...but I get an error message.

Thx,

M
From: Michael Gibson
3 Jul 2019   [#6] In reply to [#5]
Hi Mat,

re:
> I looked at the Import/Export options in MoI "OBJ options"...scale factor is at "1". I'm assuming that means 1:1 scale?

That option is only for OBJ export out from MoI, it doesn't have any effect for the SubD importer.


> Blender test model is 430.0mm wide...but imports to MoI at 0.43mm.

That's for your "Box_2_subD_test.obj" file? I opened that file in several other applications like Rhino and Silo and get the same result as in MoI.

It sounds like this could be a bug or quirk in the Blender OBJ exporter, it seems like it might be rescaling the output to be in meters units instead of just keeping the existing coordinates without any modification. But there is nothing in the OBJ spec that says that it should be in meters.

Or perhaps you are actually working in meters in Blender and not in mm like you think you were?

One way you can solve it would be to switch your MoI units to meters before you do the import, then switch it back to mm after you've done the import.

Another solution would be to set the Blender option for scaling the output, the control for it is shown in the lower left area of the Blender window when you do the export. Scroll down to the bottom and set the Scale option there, set it to 1000. There is a description of this here:
https://blender.stackexchange.com/questions/17966/blender-units-vs-metric


> > Max's ImportOBJ script
> Tried Max's "exact" trick..."_ImportOBJ exact.htm" and "_ImportOBJ exact.js" Command files...but I get an error message.

The error message is coming from adding the .htm or .js at the end there. You need it to be: "_ImportOBJ exact" without any additional stuff added to the end.

- Michael
From: mat10x
3 Jul 2019   [#7] In reply to [#6]
Hi Michael,

A. Blender > MoI scale

"That's for your "Box_2_subD_test.obj" file?"
I tested a particular project file. The Blender units are set in Millimeters....and I have MoI set up in MM as well. If I switch MoI to Meters...I get the same scale issue import result.

Switching Blender export scale to 1,000 as you suggested works...and the x/y/z position is now also correct. Now the MoI import is much closer...still off by a tad though.

Blender
X: 210mm
Y: 428mm
Z: 42.4mm

MoI
X: 210.41 (Measures 210.38 when measured point to point in MoI, but 210.41 general measurement, see image).
Y: 427.79
Z: 42.37

Center to center measurement of the bars seems spot on at 403.55mm.

B. Import OBJ
- Took off the .htm and .js...still no go. Image attached.

Thanks Michael.

M

Image Attachments:
Blender_measurements.png  Blender_Units.png  ImpObj_command_files.png  MoI_Measurements.png  MoI_Units.png  MoI_width.png  MoI_X_measurement.png 


From: Michael Gibson
3 Jul 2019   [#8] In reply to [#7]
Hi mat,

re:
> B. Import OBJ
> - Took off the .htm and .js...still no go. Image attached.

It looks like you're renaming the file names in your commands folder. That won't do what you need - the link above (http://moi3d.com/forum/index.php?webtag=MOI&msg=6674.453) is about setting up a shortcut key, you do that inside MoI in the Options dialog Shortcut keys
section, not inside the macOS Finder.

If you set up a shortcut key (in the MoI Options dialog) with "_ImportOBJ exact" as the command part of the shortcut key, then you would trigger the command by pressing the shortcut key.

But also another way you could get it set up would be to modify the _ImportObj.js script file in a text editor so that the "exact" behavior is the default. Then you would not need to set up a parameter for it and you would also be able to use the button for it instead of a keyboard shortcut.

To do that, open up _ImportObj.js in a text editor and go to line number 10 which has this currently:

code:
if ( moi.command.getCommandLineParams() ==='exact' ) { moi.ui.commandUI.normalizeObj( false ) } else { moi.ui.commandUI.normalizeObj( true ) }


replace it with this instead:

code:
if ( true ) { moi.ui.commandUI.normalizeObj( false ) } else { moi.ui.commandUI.normalizeObj( true ) }


Hope that works for you!

- Michael
From: Michael Gibson
3 Jul 2019   [#9] In reply to [#7]
Hi mat,

re:
> Now the MoI import is much closer...still off by a tad though.

Maybe your bounding box measurement in Blender is giving you the bounding box of the control polygon hull, while in MoI it's giving you the bounding box of the smoothed subdivision surface?

- Michael
From: mat10x
6 Jul 2019   [#10] In reply to [#8]
Hi Michael,

Hope you had a great 4th!

- ImpOBJ text editor script change works great!

- "Maybe your bounding box measurement in Blender is giving you the bounding box of the control polygon hull, while in MoI it's giving you the bounding box of the smoothed subdivision surface?"
Hmm, I'll have to look into that possibility.

Thanks so much for all your help!

M