-- Created: March 01 2016 -- Version: 3ds Max 2016 -- Script: MissingTexturesManager.ms -- Description: This script finds missing texture paths and offers the possibility to ignore, remove or replace them -- Authors: Pedro Zuņeda Garrido & Carlos Monteagudo Maņas sceneroot = (for r in (refs.dependents rootnode) where (classof r == Scene) collect r)[1] n_assets = AssetManager.GetNumAssets() count = 1 assets = #() missingPaths = #() missingNames = #() fn searchMissingAssets = ( for i = 1 to n_assets do ( asset = AssetManager.GetAssetByIndex i asset_name = asset.GetFileName() state = (atsops.GetFileSystemStatus asset_name) as string if (state == "#(#missing)") then ( append assets asset local AID = asset.GetAssetId() --get the Asset?s ID local AType = asset.getType() --get the Asset?s Type local AFile = asset.getfilename() --get the Asset?s File Name format "ID:% Type:% File:%\n" AID AType AFile --format the info local lFile = filenameFromPath AFile local lPath = getFileNamePath AFile append missingPaths lPath append missingNames lFile ) ) ) fn createRollout = ( if (missingPaths.count == 0 or missingNames == 0) then ( rollout zeroMissingAssets "Missing Assets" ( label label1 "No missing assets." offset:[0,10] button button1 "Ok" border:true width:50 offset:[0,15] on button1 pressed do destroyDialog zeroMissingAssets ) createDialog zeroMissingAssets 170 80 ) else ( rollout missingAssets "Missing Assets" ( local oldFilename = missingPaths[count] as string + missingNames[count] as string local newFilename = "" label label1OldFilename "Missing Asset:" pos:[10, 10] width:400 height:20 label label2OldFilename oldFilename pos:[90, 10] editText editNewFilename "New Filename:" pos:[10, 35] width:405 height:15 button explorer "..." border:true pos:[430, 33] width:28 button omit "Omit" border:true pos:[232, 80] width:110 button replaceFilename "Replace path" border:true pos:[354, 80] width:105 -- Omit Current Missing Error on omit pressed do ( count += 1 destroyDialog missingAssets if (count <= missingPaths.count) then createDialog missingAssets 466 115 ) -- Replace Missing Path on replaceFilename pressed do ( if newFilename != "" then ( newPath = getFilenamePath newFilename newFile = filenameFromPath newFilename local finalPathName = newPath + newFile local asset_name = assets[count].getfilename() atsops.RetargetAssets sceneroot asset_name finalPathName CreateOutputFolder:false atsops.Refresh() count += 1 destroyDialog missingAssets if (count <= missingPaths.count) then createDialog missingAssets 466 115 ) else ( messageBox "Error! Enter new filename." ) ) -- Explorer button on explorer pressed do ( newFilename = getOpenFileName caption:"Select new file:" \ filename:"c:/" \ types:"All|*.*|" if (newFilename != undefined) then editNewFilename.text = newFilename ) -- EditText event on editNewFilename changed txt do ( newFilename = txt ) ) createDialog missingAssets 466 115 ) ) searchMissingAssets () createRollout ()