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

    One material type to another [SOLVED]

    PYTHON Development
    0
    2
    557
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H
      Helper
      last edited by

      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.

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        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!

        1 Reply Last reply Reply Quote 0
        • First post
          Last post