MoI discussion forum
MoI discussion forum

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

Show messages: All  1-5  6-7

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

Show messages: All  1-5  6-7