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

    Takes - material override in Python

    Cinema 4D SDK
    python
    2
    4
    726
    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.
    • S
      stanDM
      last edited by

      Hi,

      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 )
      
      ferdinandF 1 Reply Last reply Reply Quote 0
      • ferdinandF
        ferdinand @stanDM
        last edited by

        Hello @standm,

        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.

        Cheers,
        Ferdinand

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 0
        • S
          stanDM
          last edited by

          Hi Ferdinand,

          thanks a lot!

          1 Reply Last reply Reply Quote 0
          • ferdinandF
            ferdinand
            last edited by

            Hello @stanDM,

            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,
            Ferdinand

            MAXON SDK Specialist
            developers.maxon.net

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