Notifications
Clear all

[Closed] Replacing Bitmaps with Similar Filenames

I am trying to create a script that will go through a multi-sub and replace bitmaps with another one that have similar filenames. I have tried and examined a bunch of bitmap utility scripts, but I can’t seem to find one that will filter and compare filenames. For example, if I wanted to search a sub-material and collect all the names of the bitmaps and then replace the ones that have a similar bitmap with say “LOD” in the filename, but everything else in the name is the same. I have tried making arrays of all the bitmaps and then doing a wildcard replace, but I am missing something. Any help would be cool. Thank you.

1 Reply

In regular Max materials, the maps are each stored as a Bitmap value. As you probably know, that Bitmap value has a .filename parameter. Example, typing this in the Listener:

 meditMaterials[1].diffuseMap.filename

… would print the path/filename of the map assigned to the Diffuse Map slot. To change it to a different texture, you can set a new value to the .filename property directly, or use openBitmap to replace the whole Bitmap value. Example of the first method:

 myMat = meditMaterials[1] 
for m in myMat.maps do (
if classOf m == Bitmaptexture then (
	 m.filename = getFilenamePath m.filename + getFilenameFile m.filename + "LOD" + getFilenameType m.filename
)
)

This loops through all maps in the material found in the first Material Editor slot and adds “LOD” to the end of the filename. The code assumes the new texture is in the same folder as the original texture.

Let me know if you need more specifics.