Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Check for missing textures

    Cinema 4D SDK
    2
    4
    666
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • indexofrefractionI
      indexofrefraction
      last edited by indexofrefraction

      Hi,
      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()
      shader.InitRender(irs)
      tex_ok = True if shader.GetBitmap() else False
      shader.FreeRender()
      

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

      1 Reply Last reply Reply Quote 0
      • indexofrefractionI
        indexofrefraction
        last edited by indexofrefraction

        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

        1 Reply Last reply Reply Quote 1
        • M
          m_adam
          last edited by

          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.
          Cheers,
          Maxime.

          MAXON SDK Specialist

          Development Blog, MAXON Registered Developer

          1 Reply Last reply Reply Quote 0
          • indexofrefractionI
            indexofrefraction
            last edited by

            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

            1 Reply Last reply Reply Quote 1
            • First post
              Last post