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

    Keyframe Texture Tag with no material

    Cinema 4D SDK
    python r25
    2
    6
    873
    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.
    • a_blockA
      a_block
      last edited by a_block

      Hi,

      I feel a bit stupid. I'm trying to create keyframes on a Texture tag. Everything's fine, until I try to have a key with no assigned material in between (basically SetGeData(..., None)). Then I end up with keyframes, which seem to look right. They show nothing for the material. But the tag behaves, as if the key is not there and shows the material from the frame shown before (it does not matter, if that's the preceding frame or any other). As if the key wasn't there at all.

      In user interface this seems to work and the object correctly shows no material on such frames.

      While writing this, I seem to have the same issue with the BaseLink in Instance objects as well.

      I must be doing something awfully wrong. I also tried FlushData() in these cases, but this didn't help either.

      TL;DR: How do I set a BaseLink parameter keyframe to an empty link?

      Any help would be much appreciated.

      Thanks in advance,
      Andreas

      1 Reply Last reply Reply Quote 0
      • M
        m_adam
        last edited by m_adam

        Hi @a_block there is currently an issue were the internal conversion of a GeData fail if this is None (this will be fixed within the next Cinema 4D version).

        As a workaround you can call SetGeData with a temporary Material. Then you delete the object, therefor the BaseLink will then be empty.

        import c4d
        
        
        def main():
            if not op:
                return
            
            tag = op.GetTag(c4d.Ttexture)
            
            track = tag.GetFirstCTrack()
            if track.GetDescriptionID()[0].id != c4d.TEXTURETAG_MATERIAL:
                raise RuntimeError("'Material' track not found")
            
        
            curve = track.GetCurve(c4d.CCURVE_CURVE)
            if curve.GetKeyCount() < 1:
                raise RuntimeError("Curve has no keys.")
            
            key = curve.GetKey(0)
            
            mat = c4d.BaseMaterial(c4d.Mmaterial)
            key.SetGeData(curve, mat)
            mat.Remove()
            
            c4d.EventAdd()
        
        # Execute main()
        if __name__=='__main__':
            main()
        

        Cheers,
        Maxime.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        1 Reply Last reply Reply Quote 1
        • a_blockA
          a_block
          last edited by

          Hi Maxime,

          thanks for the prompt help, much appreciated.
          I like your thinking with the workaround. 😉

          This topic can be marked solved, unless you want to keep it open to add not on the fix later on.

          Cheers,
          Andreas

          1 Reply Last reply Reply Quote 0
          • a_blockA
            a_block
            last edited by

            Thinking about it, is the mat.Remove() needed at all? After all the material is not inserted in the usual way in this case, it should get wiped when going out of context anyway.

            M 1 Reply Last reply Reply Quote 0
            • M
              m_adam @a_block
              last edited by m_adam

              @a_block said in Keyframe Texture Tag with no material:

              Thinking about it, is the mat.Remove() needed at all? After all the material is not inserted in the usual way in this case, it should get wiped when going out of context anyway.

              Right, but then I need to explain garbage collector for next readers. So the garbage collector is a mechanism by Python that have the duty to clean memory. This is usually done at the end of the scope. Since we do not add the material into a document, this is the python variable, who take care of holding this material. If you delete the variable, the Material is then automatically deleted.

              Cheers,
              Maxime.

              MAXON SDK Specialist

              Development Blog, MAXON Registered Developer

              1 Reply Last reply Reply Quote 2
              • a_blockA
                a_block
                last edited by

                Sorry, for causing extra work

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