One material type to another [SOLVED]

On 30/06/2018 at 06:09, xxxxxxxx wrote:

Hi Sebastian and Eldiren,

I found the comment on this post VERY interesting to me. I'm trying to replace a current material for a new created one (avoiding to do the replacement in all the Tags). As far as I understand, you suggest that we can replace the material connections using the TransferGoal function.

this is how looks that portion of the code in my script... you think am I doing right? not working at the mo.

    #iterate over native C4D materials
    matLoop = doc.GetFirstMaterial()
    while matLoop:
        if matLoop.GetType() == c4d.Mmaterial:  
            
            print matLoop
            oldmat=matLoop
            newmat=ConvertMaterial(oldmat)
            oldmat.TransferGoal(newmat,False)
                        
        matLoop = matLoop.GetNext()

I can't find any other example of this through the Internet :)))

Eldiren, I would be so amazing if you can share the portion of code you finally managed to do the task!

Thanks in advance!
Julio.

On 30/06/2018 at 12:58, xxxxxxxx wrote:

Ok, I found the mistake myself :)
I needed to jump to the next object before doing the materials swap.

This is the correcty way, and work like a charm ;)

#iterate over native C4D material
matLoop = doc.GetFirstMaterial()
while matLoop:
	if matLoop.GetType() == c4d.Mmaterial:
            
		oldmat=matLoop
		newmat=ConvertMaterial(oldmat)
		matLoop = matLoop.GetNext()
		oldmat.TransferGoal(newmat,False)

Thanks guys anyway!