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

    CKey left/right Python methods

    Cinema 4D SDK
    python maxon api
    2
    7
    1.1k
    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
      heilei
      last edited by

      Could someone please enlighten me: what exactly do these Python CKey left/right methods do? The documentation is somewhat... vague ๐Ÿ™‚ (the text below is taken directly from Maxon's Python API documentation pages).

      CKey.GetTimeLeft(self) : "Get the left time of this key"
      CKey.GetTimeRight(self) : "Get the left time of this key"
      CKey.GetValueLeft(self) : "Get the value of this key"
      CKey.GetValueRight(self) : "Get the right of this key"

      CKey.SetValueLeft(self, seq, v) : "Set the left value of this key"
      CKey.SetValueRight(self, seq, v) : "Set the right value of this key"
      CKey.SetTimeLeft(self, seq, t) : "Set the left time of this key"
      CKey.SetTimeRight(self, seq, t) : "Set the right time of this key"

      (as I've suggested before: Maxon should really REALLY put more resources in the API documentation quality)

      1 Reply Last reply Reply Quote 0
      • CairynC
        Cairyn
        last edited by

        These are times and values of the right and left tangents of the keys. See the C++ documentation:
        https://developers.maxon.net/docs/cpp/2023_2/page_manual_ckey.html#page_manual_ckey_edit_tangents

        Yeah, it would be fairly helpful if the word "tangent" would be mentioned in the Python docs...

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

          Thank you, Cairyn. When you document method "SplurgeMiddlePhalange()" with "this method splurges your middle phalange", you're not really helping anyone... ๐Ÿ™‚

          A followup question: is there a way to get the time and/or value of previous/next keyframe of a CKey (on the same track)? I was hoping these mysterious left/right methods would do that, but apparently not.

          CairynC 1 Reply Last reply Reply Quote 0
          • CairynC
            Cairyn @heilei
            last edited by

            @heilei Yeah, there is quite a bit of that "self-evidently documented" stuff in the C4D docs. But I'm not working for Maxon, I'm just the nagging guy ๐Ÿ˜บ

            CKey is derived from GeListNode which has the GetNext() / GetPrev() methods. So theoretically it may be possible to walk through the key list of a track by using these. But actually I see only examples where the keys are iterated by GetKey() on the curve.

            When I look at the GetNext() keys on a normal curve, it seems to be correct:

                    curve = track.GetCurve()
                    if curve is None:
                        continue
            
                    for key_id in range(curve.GetKeyCount()):
                        key = curve.GetKey(key_id)
                        print ("This:", key, 
                                    key.GetTime().GetFrame(doc.GetFps()), 
                                    key.GetValue())
                        if key.GetNext() != None:
                            print ("Next:", key.GetNext(), 
                                           key.GetNext().GetTime().GetFrame(doc.GetFps()), 
                                           key.GetNext().GetValue())
            
            

            I haven't done all that much with keys though, so maybe there is a reason not to do it by the GeListNode functions. I will leave the answer to that question to the Maxon crew.

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

              CTrack documentation talks about โ€indexโ€ a lot, when referring to keys, but I havenโ€™t yet found any definite specification for it. Are the keys indexed in what order? Time? Order of insert? Random? Does the index start from 0 or 1?

              1 Reply Last reply Reply Quote 0
              • CairynC
                Cairyn
                last edited by

                I guess this means what curve.GetKey(key_id) is for. Range starts at 0 and ends with curve.GetKeyCount()-1 (inclusive).

                I tried inserting a key through the GUI, and it appears in the correct (time) sequence, no matter whether I use the curve's key index or the GetNext method.

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

                  Ok, thanks for the clarification.

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