On 07/07/2016 at 15:12, xxxxxxxx wrote:
Here I have a somewhat basic script that takes all materials and creates c4d materials based on their names. What I really want to do is actaully create and replace all the scene with c4d ones. Useful for situations where I find myself needing to convert other render engine materials to basic ones for export. I of course get the creating part, how can I do the conversion? As it stands I run this script and then have to do alt dragging to manually replace my original materials.
from c4d import gui
def main() :
mats = doc.GetMaterials();
for mat in mats:
new_mat = c4d.BaseMaterial(c4d.Mmaterial); # create standard material
new_mat[c4d.ID_BASELIST_NAME] = mat.GetName() +"_c4d";
On 08/07/2016 at 01:19, xxxxxxxx wrote:
in Cinema 4D materials are assigned to objects using a Texture Tag. This texture tag is assigned to the object and references the used material through a BaseLink parameter. So you have to change this BaseLink on the texture tag.
The easiest way to change the BaseLinks is to use BaseList2D.TransferGoal() on the original material with the new material as an argument. This function changes all BaseLinks referencing the given original material.
On 09/07/2016 at 12:29, xxxxxxxx wrote:
That works like a dream. Thanks.