Yes, thank you so much. This works perfectly. And thanks a million for the in depth explanation.
T
Latest posts made by tankun
-
RE: Copy the texture in the Reflection channel to the Color channel
-
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.