Solved Check for missing textures

as the R21 Asset Inspector is buggy and not working correcty,
I'm trying to check myself for a reliable missing texture info.

I thought i could simply traverse the materials / shader tree
and check all XBitmaps with shader.GetBitmap()
thinking that a return value of None would mean, that texture is missing.

but somehow this doesnt seem to work,
It seems I also get None for existing textures....

Is it possible to check if a shaders texture is accessible for c4d?

best, index

i tried something like this (for each bitmap shader) :

irs = c4d.modules.render.InitRenderStruct()
tex_ok = True if shader.GetBitmap() else False

actually the return value of InitRender() should be enough already,
but I get -101 c4d.INITRENDERRESULT_ASSETMISSING also for loaded textures... :-/

ok! finally, it is imporant to use the doc to get the irs !
now it works.

irs = c4d.modules.render.InitRenderStruct(doc)

but question:
is this the only / best way to check if textures are missing?

an alternative would be to actually check if the file is existing somewhere in the given paths

Hi @indexofrefraction,

your way is correct and as you find you have to use the document to properly handle texture (since texture may be relative to this current document).

This one is possible but a bit slow because you initialize the whole shader, but this is also the most reliable
Other solutions are:

  • c4d.GenerateTexturePath, given a file path(even relative) will generate a texture path. Then with os.path.exist you can test if this path really exists (Not the case in all conditions but pretty fast)
  • Use c4d.documents.GetAllAssetsNew. This will give you all the missing assets of a document.

Finally for more detailed answers find Know the change of bitmap.

hi and thanks Maxime !

GetAllAssetsNew() is S22 only,
and I had problems with InitRender() and Vray Bitmaps

so I decided to manually check for the files...
I had it already, but GenerateTexturePath() shortens the code quite a bit, because I dont have to check all possible paths.

It seem GenerateTexturePath() returns the absolute path, if the file is found somewhere in the texture paths, otherwise it returns None.

needs some testing, but until now it seems to work well.

best, index