Best material replacement workflow when exporting from Solidworks to Unreal?

I have been working with exporting large CAD models (~10,000 parts) into Unreal Engine using Datasmith and have been very impressed by the speed and automation of it. However, a major sticking point has been the materials. With the default Datasmith Master Material, all the diffuse colours import correctly from Solidworks but as they are just simple diffuse materials in Unreal, I need to edit them to add textures and other parameters such as metalness etc. I have used Keyshot extensively in the past and it has a simple material replacement function that finds imported material names and replaces them with a material from the Keyshot library based on the material names.

I have created a modified master material that is setup to take PBR textures with additional parameters liek metalness etc but when I replace the initial Datasmith Master Material with this new one I lose all the colour information on the parts, and manually finding and linking materials is very time consuming with so many parts.

I have searched online and there are a few topics about a python script to automate the material replacement for Unreal Engine but I can’t find any solid info on it.

My main question is whether this is the best workflow?

And if so, is it possible for a python script to find and replace the basic initial materials with high quality PBR materials I add to the project? For example, many of the parts use the same default steel material from Solidworks, could a python script find all the meshes with this material and replace it with a new PBR steel material I have created? Thanks

Through visual dataprep or editor utility blueprint function you can use the
“Substitute Material” or “Substitute Material by Table” Dataprep Operation Reference in Unreal Engine | Unreal Engine 5.3 Documentation

Basically these functions replace material on actors/asset, based on their names with new materials you would have define. But that is a blunt swap of material, no smart transfer of properties from one to the other.

Else you will need to do a python script or a editor utility widget that will:

  1. loop on assets OR actors in the scene that have static mesh component
  2. loop on their materials
  3. copy some properties from those materials (like base color)
  4. generate a new material instance from your master
  5. modify the new material properties with your base color
  6. apply new materials.

Some python example to create/edit materials are here PythonSamples/scripts/Create at main · ue4plugins/PythonSamples · GitHub
Basically you need to use functions from the Material Editing Library

Substitute Material looks like exactly what I’m looking for, but I’ll take a look into the Python scripts also. Thanks, that’s super helpful.