Hello,
I am looking for a script that will automatically create a new basic material and apply it to the selected layer, with the material name being the same name as the layer name. It should work on multiple selected layers at once and each material should be a different color.
For example, if I have 3 layers, say “roof”, “walls” and “floors”, I would select them and run the script, and the script would create new materials named “roof”, “walls” and “floors” and assign them to the respective layer, while giving every material an individual color.
I need this to save time when exporting rhino geometry into Twinmotion. Twinmotion is a real time rendering software that can import .fbx or .skp files. When doing so, it collapses the geometry into a single object, for example every object on the layer “walls” would turn into one single object. This makes it easier to apply textures. While Twinmotion offers the choice to “keep hierarchy” when collapsing, this often does not work and causes a huge mess of layers to appear in Twinmotion. “collapse all” turns every imported layer into one single object, making it useless for importing many layers at once. The only remaining and most reliable option is “collapse by material”, which, as the name suggests, collapses every object with the same material into one layer.
To stay with our example, if I applied respective materials to the layers “roof”, “walls” and “floors” and exported them as a .skp file, then import them into Twinmotion and chose the “collapse by material” option, the objects would all be collapsed in their respective layers, which would be given the names of the materials. This is why the materials must have the same name as the layers, otherwise I would end up with layers named “default material” or “basic material 1”, which would be useless for further editing in Twinmotion.
I hope I kinda got across what I’m looking for. I have no clue about scripting, and a search of the forum and internet didnt turn up what I need. So I’m looking for help here. Thank you!
If such a script does not yet exist and someone would create it for me, I’d be willing to pay for it too. It is not really that tedious to create a basic material, give it the name of the layer and pick a color. But it becomes tedious when you have to do it 30 times over for different layers, so automating this could save a lot of time and energy.