MoI discussion forum
MoI discussion forum

Full Version: Is there a way to preserve material names?

From: quasmaster
11 Dec 2023   [#1]
Hello!

I am new to MoI and I am just testing the tool in tandem with Houdini.

Currently I am in the process of researching a pipeline for automated CAD data conversion. There are other tools out there which are quite pricey when it come sto batch processing (Pixyz and InstaLOD for instance). The Houdini + MoI route looked very promising until I hit a roadblock. I need to preserve material names from the original CAD tool. Unfortunately it looks like MoI changes material names to "Level 1", "Level 2" and so on. I attached a comparison screenshot between a Pixyz Import and a MoI import of the same STEP file. I also tried IGES as import format but same behaviour there.



No matter if I go through Houdini or open the STEP file directly in MoI, the material names are overwritten.

So my question is, is there a way (or file format) that preserve the material names?

Thanks for the help! Cheers, Alex

Image Attachments:
moi_materials.png 


From: Michael Gibson
11 Dec 2023   [#2] In reply to [#1]
Hi Alex, the STEP and IGES file formats do not contain any mechanism in them for material names, they just contain color values that are set on surfaces.

The main way to preserve material names is to use either OBJ or FBX file formats for the export out from MoI, try those.

- Michael
From: PaQ
11 Dec 2023   [#3]
In the Pixyz example, the material name looks just like the surface color encoded in a hex way ... I doubt it was the original CAD material name.

Beside Dom did a Moi parser you can run inside Houdini :
https://www.youtube.com/watch?v=DE5ygN9ZBFA

It won't help to keep the original CAD material assignment, if nor IGS or STP can care them, the only way would be .3dm ?
From: Michael Gibson
11 Dec 2023   [#4] In reply to [#1]
Sorry I was a little confused and was thinking that you were talking about exporting files that had been created in MoI.

There may be a method for transferring "layer" names in STEP that was added in newer versions of the STEP file format. MoI does not currently have support for that but if you have a small example STEP file that contains that if you can post that I may be able to add support.

- Michael
From: quasmaster
12 Dec 2023   [#5]
Thanks for all the replies.

Yes, keeping the hex code is exactly what I need. Pixyz and InstaLOD for example use this hex code as material name when importing the step file as seen on the screenshot before.

The requirement for me is to carry this hex code/material name all through the optimization pipeline. At a later stage proper PBR materials will be applied via script based on the material name/hex code each part carries. So for example parts with the color #a5a5a5ff in the step files will always get the PBR material for stainless steel, let's say "mat_metal_steel_stainless".

With MoI this is not possible at the moment it seems. The original hex codes/material names are "destroyed" and replaced with the "Layer 1", "Layer 2", etc. labels.

Thanks for looking into it. Maybe this feature can be added easily?

I attached a simple step file with 3 cylinders, each with a different color applied to them. "Color #bdefefff", "Color #c76363ff" and "Color #cdcdeaff".

Cheers, Alex


Attachments:
3_cyls_3colors.step

Image Attachments:
moi_3cyls.png 


From: Michael Gibson
12 Dec 2023   [#6] In reply to [#5]
Hi Alex, the example STEP file does not seem to have any layers set up in it. Those would be some PRESENTATION_LAYER_ASSIGNMENT entries in the file.

So the material names "Color #bdefefff", "Color #c76363ff" and "Color #cdcdeaff" in Pixyz and InstaLOD do not seem to be coming from preserving material names, they are just cooking up that name from the color value.

It is possible to set up a script in MoI to do the same thing. To do that inside MoI go to Options > "Shortcut keys" and add in a new shortcut key and for the command part of the shortcut key put in this:

script: var styles = moi.geometryDatabase.getObjectStyles(); for ( var i = 0; i < styles.length; ++i ) { var style = styles.item(i); style.name = 'Color ' + style.hexcolor.toLowerCase() + 'ff'; }


If you then trigger that shortcut key after loading the step file, the style names in MoI should change from "Level 1", "Level 2", etc... to instead be "Color #cdcdebff", etc... The script just renames all styles to have a name derived from the style's color value.

- Michael
From: quasmaster
12 Dec 2023   [#7] In reply to [#6]
Hi Michael!

Wow, thanks! That was fast! The script does the trick!

Now the only downside is that I have to manually press the shortcut key for every import. For now this will do fine to further test this approach! Maybe in a future version this line of code could be added to the MoI importer. But I guess the "Level 1", "Level 2" nomenclature is important for other workflows.

Thanks again for the amazingly fast help! Cheers, Alex