Set texture path to ="" for 1) all textures in scene 2) all missing textures in scene


#1

I have been looking everywhere on the internet for solution that keeps the material structure, but only clears the texture file from whatever node is holding it, ie Bitmap, VrayHDRI etc.
I already have scripts for clearing the material altogether.

Could anyone please help with the following

  1. set all textures-path in scene to =""
  2. set all missing textures in scene to =""

#2

it’s a simple thing if we need to replace ‘missing’ texture-paths of only bitmaptextures:

txs = getclassinstances bitmaptexture
for tx in txs do
(
	if not iskindof tx.filename String or not doesfileexist tx.filename do tx.filename = ""
)

finding all the “missing” bitmaps and their owners is a problem. developers usually keep this “secret” as a treasure for their own use


#3

Thank you very much @denisT

This is what I ended up with. I will probably need to try it out in different situations, for example what happens if I don’t have Vray?

  1. clearing all textures, VrayHDRI and Proxys
-- This script clears all available instances of bitmap textures, VrayHDRI maps and VrayProxy file links
-- Thanks to denisT for helping with the maxscript for finding and clearing the textures

format "----------------------------------------------------------------------------------\n"
format "Clearing all available instances of bitmap textures and VrayProxy file links in this scene\n"
format "----------------------------------------------------------------------------------\n"

txs = getclassinstances BitmapTexture + getclassinstances VRayProxy
for tx in txs do
(
	print tx.filename
	tx.filename = ""
)


format "-----------------------------------------------------------\n"
format "Clearing all available instances of VrayHDRI maps in this scene\n"
format "-----------------------------------------------------------\n"
Htxs = getclassinstances VRayHDRI
for tx in Htxs do
(
	print tx.HDRIMapName
	tx.HDRIMapName = ""
)

atsops.refresh()
  1. Secret or not, this is my solution for how to clear the unresolved textures. Even though I am grateful for the AssetTracker-code (se credit below) I hope someone might know a cleaner way to resolve paths:
    -- This script clears all missing instances of bitmap textures, VrayHDRI maps and VrayProxy file links
    -- Credit goes to TreeDwannaB for the path resolving solution (https://forums.cgsociety.org/t/get-texture-absolute-path/1685901/13)
    -- Thanks to denisT for helping with the maxscript for finding and clearing the textures

    fn clearFiles =
    (
    txs = getclassinstances BitmapTexture + getclassinstances VRayProxy -- clears all Bitmap textures and VrayProxy files
    for tx in txs do
    (
    	if not doesfileexist tx.filename do 
    	(
    		print tx.filename
    		tx.filename = ""
    	)
    )

    Htxs = getclassinstances VRayHDRI -- clears all VrayHDRI textures
    for tx in Htxs do
    (
    	if not doesfileexist tx.HDRIMapName do 
    	(
    		print tx.HDRIMapName
    		tx.HDRIMapName = ""
    	)
    )
    )

    fn resovlePaths =
    (
    	ATSOps.ExcludeOutputFiles = true
    	actionMan.executeAction -841213575 "2"  -- Asset Tracking System: Highlight Editable Assets
    	actionMan.executeAction -841213575 "16"  -- Asset Tracking System: Make Path Relative to Project Folder
    	actionMan.executeAction -841213575 "2"  -- Asset Tracking System: Highlight Editable Assets
    	actionMan.executeAction -841213575 "17"  -- Asset Tracking System: Make Path Absolute
    	ATSOps.ClearSelection() 
    	gc()
    )

    fn ATnClear =
    (
    	if ATSOps.Visible == false then
    	(
    		ATSOps.Visible = true
    		resovlepaths()
    		print "Resolved Paths Done"
    		print "Clearing missing or non resolved file path:"
    		clearFiles()
    		atsops.refresh()
    		ATSOps.Visible = false
    	)
    	else
    	(
    		resovlepaths()
    		print "Resolved Paths Done"
    		clearFiles()
    		atsops.refresh()
    	)
    )


    ATnClear() 

#4

You are going right direction. Good for you is that you know where to search for missing textures, and you know what property has file pointer.

But there are many cases when you don’t know it. You have only message (warning) that some specific textures (file paths) are unresolved.

AssetManager is a good thing. But it also doesn’t tell you where these ‘file paths’ were missing. AssetManager can solve some ‘missing’ (as you show above for example), but it can’t solve ‘missing’ bitmap in real-time shaders for example.

So the ‘secret’ remains a secret… :wink:


#5

I gotta say I had no idea bout any real-time shaders, so that itself was quite a secret then! :wink:
I dont know how common real time assets are, and how often you would encounter missing textures. In other words, if its not that common, these “few” assets could be fixed by hand.

On the other hand, retrieving assets with more commonly used shader increases the chance to encounter assets with one or two missing bitmaps. So instead of totally killing them with $.material = undefined I figured out I needed something that keeps the material setup intact at least.

What about the AssetManager hack - is there any nicer way to refresh / turn into absolute paths - something that does not lie in the realm of secrets?