DETECT AND CLEAN UNUSED TEXTURE FROM THE SCENE

how to detect is a texture used on any object or not!
Lets say I have in my scene missing textures that are not used at all in my scene, or may be I have an object with ids: 1,2,3 with a multimaterial with 4 IDs where the textures

001.jpg for ID 1
002.jpg for ID 2
003.jpg for ID 3 and
004.jpg for ID 4!

It means there are 2 situation:
004.jpg is used in material and is unused in object!
It would be wonderful to list textures as following:

in objects
d:\folder\textures\001.jpg used
d:\folder\textures\002.jpg used
d:\folder\textures\003.jpg used
d:\folder\textures\004.jpg unused

and for example I want to delete the unused material with all its textures from multisubmaterial!

Any comments and ideas are welcome!

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
artrender.info's picture

Smth from Barigazy:

This is how to clean:

for i in 1 to meditMaterials.count where (MeditUtilities.isMaterialInUse meditMaterials[i] == false) do meditMaterials[i] = Standard()
--Sometime asset tracking hold path strings
ATSOps.Refresh()
--is good to use this function at the end
freeSceneBitmaps()

This is how to detect textures in modifiers:

modTexMaps = #()
for obj in geometry where obj.modifiers.count != 0 do
(
	for m = 1 to obj.modifiers.count do
	(
		for p in (getpropnames obj.modifiers[m]) \
        where isKindOf (tex = getproperty obj.modifiers[m] p) texturemap do 
		(
			append modTexMaps tex
		)
	)
)
modTexMaps
barigazy's picture

...

Search about mapPaths struct inside mxs help.

bga

artrender.info's picture

oh!

You answer so fast!!!

barigazy's picture

example

for i in mapPaths.count() to 1 by -1 do mapPaths.delete i
mapPaths.add @"c:\3ddd1366191879\"
mapPaths.getFullFilePath "glare_streaks_star_camera_filter.tif"
--"C:\3ddd1366191879\Program Files\Autodesk\3ds Max Design 2012\Maps\glare\glare_streaks_star_camera_filter.tif"

bga

barigazy's picture

If mapPaths.getFullFilePath

If mapPaths.getFullFilePath returns empty string them map is missing.
-----------------------------------------------------------------------
U can use function "usedMaps()" to what is used in the scene.
Also u can predefine map classes like bitmaptex, VrayHDRI etc. then use "getclass instance" of theses clasess. After that search for the property which hold string. If not exists then collect only theses maps and search which material have this and in which slot they are. And at the and use function
setproperty testmaterial diffusemap undefined

bga

artrender.info's picture

the bigest difficulty that I

the bigest difficulty that I have is to detect unused textures in scene and to find where are (were) they located in 3d max scene (materials, modifiers, viewport background, lights etc)!

I use to download often 3d models from internet and there are models that were "saved selected as" from their native scenes inside which there were missing files! Now when I open this model, I get missing files! How to clean them? There are cases when they are not in mtl editor, not in mtl slate mode! Nowhere! Here is an example

http://www.scriptspot.com/files/3ddd1366191879.rar

Take a look to this max file! How to detect the location of its 2 missing files through script? and how to clean them?

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.