Notifications
Clear all

[Closed] how do i delete unused texture maps with mxs?

hello ,all I am new comer here,and i was previously a maya user.

my question is how to delete unused texture maps , what i mean is when i open a max scene, max complains about PSD texture map missing, and I didn’t use any psd maps in my scene, I created some during the earlier working stage, but in the final version file i deleted all the unused materials. and i can’t see any psd maps in material editor–> get material –> scene.



mBitmaps = getClassInstances BitmapTexture
for m in mBitmaps do

 (

		dependant=undefined
		 dependant = refs.dependents m immediateOnly:true
		print "
======= start==========="
		print m.filename
		for i in dependant do print i
		print (classof i)
		print (superclassof i)
		print "======= end==========="
 --exit
  
 )


It seems these are unused garbage bitmap texture instance in my scene, how can i determin whether an instance is connected to a material or not , and how do i delete them ?

Thank u guys for any clues

2 Replies
1 Reply
(@rustyknight)
Joined: 11 months ago

Posts: 0

I’m not 100% sure, but if “i” is a material, depending on what type of material, couldn’t you just set the reference to undefined.

ie

if (classof i == standard_material) do (
 i.diffusemap = undefined
)

You’d have to do some more invesitigation into what slot the offending bitmap exists, but I think that might work…

ps – I like the use of refs…had to look that up…

Shane

for each instance of bitmaptex, i check if they r in array usedmaps, if not, then replace the instance with a custom “empty” instance.

dunno if it is correct, but it does remove the “ghost” texture when i open my scene


 
 		fn hjRemoveGhostTex=
 		(	
 			result=0
 			fn allUsedMaps =
 			
 			(
 			
 				sceneMaps = usedMaps()
 				
 				for m in meditmaterials do join sceneMaps (usedMaps m)
 				
 				sceneMaps
 			
 			)
 			
 			
 			local allUsedMaps = allUsedMaps ()
 			
 			mBitmaps = getClassInstances BitmapTexture
 			
 					    
 			tmpTex = createInstance BitmapTexture
 			
 			for m in mBitmaps do
 			(	
 				index = findItem allUsedMaps m.fileName
 				if index >0 then 
 				(
 					print ("used map : " + m.fileName)
 				)
 				 else
 				(	
 					result=1
 					print ("garbage map : " + m.fileName)
 					replaceInstances m  tmpTex
 					
 				)
 			
 			)
 			 
		 
 		result
 		)