I am dynamically generating takes in Python and I need to override material (replace one material with another one) on specific object. I have found a script which allows you to override material color, but I have no clue how to override the whole material.. any ideas?
for i in xrange(10):
takeName = "Variation " + str(i)
materialVariation = takeData.AddTake(takeName, None, None)
if materialVariation is not None:
materialColorParameter = c4d.DescID(c4d.DescLevel(c4d.MATERIAL_COLOR_COLOR, c4d.DTYPE_COLOR, 0))
hsv = c4d.Vector(float(i) * 0.1, 1.0, 1.0)
rgb = c4d.utils.HSVToRGB(hsv)
overrideNode = materialVariation.FindOrAddOverrideParam(takeData, material,materialColorParameter, rgb)
if overrideNode is not None:
overrideNode.UpdateSceneNode(takeData, materialColorParameter )
thank you for reaching out to us.
You must override the TEXTURETAG_MATERIAL parameter of the texture tag which is referencing the material you want to replace. Please note that you can only override existing parameters, you cannot add new ones. E.g., you cannot have a main take where object A has not material tag and a take 1 where A then has a texture tag and a material assigned to it. A must also already have that texture tag in the main tag. But the texture tag can be empty, i.e., link to no material.
The topic of creating takes for texture tags has been discussed in the topics Override Material Tag in Take (C++ & Overriding the material) and Changing Material Projection in Takes using Python (Python & Overriding the projection of a material) extensively. I would invite you to read both topics. When then problems remain, please feel free to ask follow-up questions.
thanks a lot!
without any further questions and other postings, we will consider this topic as solved and flag it as such by Friday, 17/06/2022.
Thank you for your understanding,