Notifications
Clear all

[Closed] search for bitmap texture and replace

This only works for materials applied into scene objects (thus the scenematerials) if you want it to work in the materials present in the material editor slot that are not applied to any object in the scene, just change “scenematerials” to “meditmaterials” and it should work.

Had some free time…

(
	rollout dRemoveBitmaps "Remove Bitmaps"
	(
		mapbutton choosemap "Select bitmap" tooltip:"Select bitmap to remove" width:120
		checkbutton btn_scene "Scene" checked:true across:2
		checkbutton btn_medit "MEdit" checked:false
		button btn_doit "Do it!" align:#center
		hyperlink hl_al "Artur Leão" address:"http://www.dimensao3.com/al" align:#center
		
		local mapToSearch
		
		on btn_scene changed state do
		(
			btn_medit.state = not state
		)
		on btn_medit changed state do
		(
			btn_scene.state = not state
		)
		
		on choosemap picked texmap do
		(
			print(classof texmap)
			if classof(texmap) == BitmapTexture then 
			(
				mapToSearch = texmap.filename
				choosemap.caption = mapToSearch
				choosemap.tooltip = choosemap.caption
			)
			else messageBox "You can't do it!" 
		)
		
		on choosemap rightclick do
		(
			mapTosearch = ""
			choosemap.caption = "Select bitmap"
			choosemap.tooltip = "Select bitmap to remove"
		)
		
		on btn_doit pressed do
		(
			if choosemap.caption != "Select bitmap" then
			(
				case of
				(
					(btn_scene.state):
					(
						for i in scenematerials do
						(
							for m=1 to getNumSubTexmaps i where classof(getSubTexmap i m) == BitmapTexture do if (pathConfig.convertPathToLowerCase  (getSubTexmap i m).filename) == (pathConfig.convertPathToLowerCase  mapToSearch) then setSubTexmap i m undefined
						)
					)
					(btn_medit.state):
					(
						for i in meditmaterials do
						(
							for m=1 to getNumSubTexmaps i where classof(getSubTexmap i m) == BitmapTexture do if (pathConfig.convertPathToLowerCase  (getSubTexmap i m).filename) == (pathConfig.convertPathToLowerCase  mapToSearch) then setSubTexmap i m undefined
						)
					)
				)
		)
		)
	)	
	createDialog dRemoveBitmaps
)

here is my version:


fn wipeBitmapTextures file:"" useFullPath:off =
(
	if useFullPath do file = pathConfig.mapPaths.getFullFilePath file
	for tx in (getclassinstances bitmaptexture asTrackViewPick:on) where iskindof tx.anim.filename String do 
	(
		f = tx.anim.filename
		if useFullPath do f = pathConfig.mapPaths.getFullFilePath f
		if (pathConfig.pathsResolveEquivalent f file) do
		(
			for s=1 to tx.client.numsubs where tx.client[s].value == tx.anim do tx.client[s].value = undefined
		)
	)
)
/*
wipeBitmapTextures file:@"c:\blabla.bla"
*/

Denis,

I have tried your code to delete all bitmap textures, but cant seem to get it to work.

I take it this is it’s function to delete “ALL” bitmap textures. If so I must be doing something wrong.
I’m still very new to maxscript, but I copy and pasted the code into the Editor window and hit Evaluate All. Normally seems to work.

Any ideas?

Many thanks

delete all texturemaps:


 fn wipeAllBitmapTextures =
 (
 	for tx in (getclassinstances bitmaptexture asTrackViewPick:on) do 
 	(
 		for s=1 to tx.client.numsubs where tx.client[s].value == tx.anim do tx.client[s].value = undefined
 	)
 )
 

Sorry Denis,

Still no luck. I get nothing happen when I Execute the code? I have tried both Standard and Vray materials, but all maps remain. Wierd?

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

i’m sure it works. probably you execute it wrong… execute the function definition first and call this function:


wipeAllBitmapTextures()

Must be a thing set up through work which is blocking it!

Keep getting error

– Error occurred in tx loop; filename: \(then a long network location)
– Frame:
– tx: TrackViewPick:“Diffuse map”
– called in wipeAllBitmapTextures(); filename: \(then a long network location)
– Frame:
** system exception **
wipeAllBitmapTextures()
OK

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

try to run


getclassinstances bitmaptexture asTrackViewPick:on

do you have the same error message?

do you have missing textures in your scene?

Denis,

You did it! works great now.

Thanks a lot for your patience and help, much appreciated.

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

… not just now, it always worked

JForrester, if you’re new to maxscript, try copy pasting my above code and evaluate it, it will bring up a window and maybe it’s easier for you to work with.

Page 2 / 2