Download

Is there any way to access the Build Settings of a static mesh through the Python API?

I’m hoping to write a script that will allow me to batch-edit all static meshes within a folder and change their Build Settings, specifically the Min Lightmap Resolution. Is there any way to do this currently? I can’t find anything in the Python API. The only lightmap-related parameter exposed in unreal.StaticMesh is Lightmap Resolution (not allowing you to adjust the padding).

If I recall correctly, a lot of that static mesh stuff is handled in the mesh editor UI code, not on the mesh object itself, meaning it wouldn’t be possible to update it through script, or if you could you’d end up with some dependent logic not being run causing further problems.

I know a staff member referenced it somewhere recently and said they are working to gradually refactor that sort of thing, but it’s a problem throughout the engine codebase, so realistically if it’s important you’d need to make the changes yourself and submit a PR, if you don’t want to wait months/years.

The Min Lightmap parameter is stored in a unreal.MeshBuildSettings object.

https://docs.unrealengine.com/4.26/en-US/PythonAPI/class/MeshBuildSettings.html

To edit any of these you need to create (or get) a unreal.MeshBuildSettings object with the right settings and then apply it to the mesh using unreal.EditorStaticMeshLibrary.set_lod_build_settings()

https://docs.unrealengine.com/4.26/en-US/PythonAPI/class/EditorStaticMeshLibrary.html