
This simple function will remove any missing Mental Ray attributes from material and
save it as new library.
fn fixMtlLib mlib_Path: suffix: =
(
if not doesFileExist mlib_Path then messagebox "This Material Library not exists!" title:"Warrning" beep:off else
(
with redraw off
(
local mlpath = getFilenamePath mlib_Path, mlname = getFilenameFile mlib_Path, new_ml = mlpath + mlname + suffix + ".mat"
local missingLegacyAssetsNames = #("mental ray: material custom attribute"), newLib = materialLibrary()
local tempLib = loadTempMaterialLibrary mlib_Path
local arr = (for i = 1 to tempLib.count collect (s = sphere() ; s.material = tempLib[i] ; s)) --; select arr
SceneConverter.RemoveMissingLegacyAssetsFromScene missingLegacyAssetsNames
for i = 1 to arr.count do append newLib arr[i].material ; delete arr
saveTempMaterialLibrary newLib new_ml
)
)
)
-- example - this is my old VRay CarPaint library.
-- use diferent file path and add suffix just to avoid any override
fixMtlLib mlib_Path:@"d:\grayroom\GR_Materials\CarPaints.mat" suffix:"_FIX"
By barigazy · 2022-02-26