Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python 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

    Display tag keyframe [SOLVED]

    Scheduled Pinned Locked Moved PYTHON Development
    4 Posts 0 Posters 381 Views
    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 Offline
      Helper
      last edited by

      On 16/06/2016 at 19:34, xxxxxxxx wrote:

      Pulling my hair out trying to keyframe the current visibility % for a display tag on the currently active object in C4D R15 using Python

      I'm trying to keyframe it at 0%, change it to 100% a few seconds later and then keyframe that.

      Can someone help please with some tips or example code? I can make keyframes, move around the timeline, etc without issue just stuck on how to do display tag keyframe specifically.

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

        On 16/06/2016 at 22:05, xxxxxxxx wrote:

        #This script creates the visibility track on the display tag  
        #Then adds two keys to the track's curve  
          
        import c4d  
        def main() :  
           
          obj = doc.GetActiveObject()  
          if not obj: return False  
          
          tag = obj.GetTag(5613)    #Get the display tag  
          if not tag: return False  
          
          tag[c4d.DISPLAYTAG_AFFECT_VISIBILITY] = True  
          
          if not tag.FindCTrack(c4d.DescID(c4d.DescLevel(c4d.DISPLAYTAG_VISIBILITY))) :      
          
              visTrack = c4d.CTrack(tag, c4d.DescID(c4d.DescLevel(c4d.DISPLAYTAG_VISIBILITY)))  
              tag.InsertTrackSorted(visTrack)  
            
              curve = visTrack.GetCurve()  
              ckey = curve.AddKey(c4d.BaseTime(0.0))['key']  #Creates a key at frame 0  
              ckey.SetValue(curve, 0.4)                      #40%  
              ckey = curve.AddKey(c4d.BaseTime(1.0))['key']  #Creates a key at frame 30  
              ckey.SetValue(curve, 1.0)                      #100%        
          
          c4d.EventAdd()  
          c4d.DrawViews(c4d.DRAWFLAGS_FORCEFULLREDRAW)       #Update the viewport and the red dot icon  
          
        if __name__=='__main__':  
          main()
        

        -ScottA

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

          On 17/06/2016 at 01:24, xxxxxxxx wrote:

          Hello,

          as you can see in Scott's example animation data is stored in a animation track represented by the class CTrack. For each animated parameter the host object stores a CTrack object. This CTrack can be obtained with FindCTrack(), if no Ctrack exsists one can be created and then added to the host object using InsertTrackSorted().

          A CTrack contains a CCurve and that CCurve contains the actual animation keyframes. These keyframes are represented by CKey objects. You can add a new key to a curve using AddKey().

          Best wishes,
          Sebastian

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

            On 17/06/2016 at 08:46, xxxxxxxx wrote:

            Thank you Scott for the demonstration and Sebastian for the explanation! It finally works 😄

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