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
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login
    1. Maxon Developers Forum
    2. tankun
    3. Posts
    T
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 2
    • Best 0
    • Controversial 0
    • Groups 0

    Posts made by tankun

    • RE: Copy the texture in the Reflection channel to the Color channel

      Yes, thank you so much. This works perfectly. And thanks a million for the in depth explanation.

      posted in Bugs
      T
      tankun
    • Copy the texture in the Reflection channel to the Color channel

      As the title suggests, I'm trying to bulk copy the layer texture in the Reflection channel to the Color channel in all the selected materials, then enabling the Color channel and disabling the Reflection channel. Here's my script:

      import c4d
      from c4d import gui
      
      
      def main():
          mat = doc.GetActiveMaterials()
          if len(mat) == 0: return
      
          for i, m in enumerate(mat):
              try:
                  layerIndex = m.GetReflectionLayerIndex(0).GetDataID()
      
                  reftex = m[layerIndex + c4d.REFLECTION_LAYER_COLOR_TEXTURE]
                  m[c4d.MATERIAL_USE_COLOR] = True
      
                  colt = c4d.BaseList2D(c4d.Xbitmap)
                  colt[c4d.BITMAPSHADER_FILENAME] = reftex
                  m.InsertShader(colt)
                  m[c4d.MATERIAL_COLOR_SHADER]  = colt
      
                  m[c4d.MATERIAL_USE_REFLECTION] = False
      
                  m.Message(c4d.MSG_UPDATE)
      
              except:
                  pass
      
      
          c4d.EventAdd()
      
      if __name__=='__main__':
          main()
      

      The layer can be the first one so that's not a problem, the script doesn't need to parse all the reflection layers, but somehow this doesn't work. I have no issues copying the texture shader from different channels but not from the Reflection channel. It's probably because Reflection channel can have many layers. But it seems I'm making a simple mistake somewhere.

      Thanks in advance.

      posted in Bugs python 2023
      T
      tankun