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

    update error?

    Cinema 4D SDK
    r20 python
    2
    10
    2.3k
    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.
    • JH23J
      JH23
      last edited by

      I was trying to include the login data inside the spline handlers but I had updating errors, I thought it was due to hierarchy but I ended up using python tags and still I had the same error, I don't know what's happening.

      SplineL.c4d

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

        Hello @jh23,

        Thank you for reaching out to us. Unfortunately, your question is not clear to us. I would in general recommend having a look at our Forum Guidelines: Structure of a Question section.

        Interpreting your script:

        I am not quite sure what constitutes 'login data' and 'spline handlers' in the sentence 'I was trying to include the login data inside the spline handlers' ? Are you talking about the initialization arguments passed to the Init method of c4d.utils.SplineLengthData? Your whole question is also missing a description of what you want to achieve and the always essential executable code listing.

        Reading the rest of the script, I assume you are trying to write the 'Depth' fields of the IK-Spline Tag with the length of the spline divided by your magic number 3.783. Since IK-Spline tag instances have dynamic descriptions, you can add and remove handles, the IDs 10004 and 10014 will not work for every tag (but do work for this one of yours). So, for me your script is doing what it is intended to do, it sets both 'Depth' fields to 5.193206487661137; although I cannot make much of what the meaning of that is due to lack of context.

        So, for more support, I would have to ask you to explain what you want to achieve, specifically in contrast to what is not working for you now.

        Cheers,
        Ferdinand

        MAXON SDK Specialist
        developers.maxon.net

        JH23J 1 Reply Last reply Reply Quote 0
        • JH23J
          JH23 @ferdinand
          last edited by JH23

          I apologize, the translator does not help much, as I said, I created a spline chain, where the depth of its handles depends on the length of the spline, my problem was that when I did it with only xpresso, it showed errors when rotating, because it took time update.

          ezgif.com-gif-maker.gif

          thinking that the error was either hierarchy, the spline node, or how to order the xpresso I did the same thing but with a python tag, despite this the same problem was present.

          import c4d
          #Welcome to the world of Python
          def main():
               spline = op[c4d.ID_USERDATA,2] # spline object
               length = c4d.utils.SplineLengthData(spline)
               length.Init(spline)
               Long = length.GetLength()
               op[c4d.ID_USERDATA,1][10004] = Long /3.783
               #[10004] = control depth 1 iKsplinetag
               op[c4d.ID_USERDATA,1][10014] = Long /3.783
               #[10014] = control depth 2 iKsplinetag
               length.Free()
               c4d.EventAdd()
          

          And speaking of the number "3,783" I used it only for my purpose as it corrected the strength of the depth of the controls
          SplineL.c4d

          ferdinandF 2 Replies Last reply Reply Quote 0
          • ferdinandF
            ferdinand @JH23
            last edited by

            Hello @jh23,

            Thank you for your update. I will take a look next week, as I won't have the time tomorrow, Friday.

            Cheers,
            Ferdinand

            MAXON SDK Specialist
            developers.maxon.net

            1 Reply Last reply Reply Quote 0
            • JH23J
              JH23
              last edited by

              Any kind of help is appreciated.

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

                Hello @jh23,

                My apologies, I forgot your thread in the 2023.1 release hectic, I will have a look next thing tomorrow morning.

                Cheers,
                Ferdinand

                MAXON SDK Specialist
                developers.maxon.net

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

                  Hello @jh23,

                  @jh23 said in update error?:

                  my problem was that when I did it with only xpresso, it showed errors when rotating, because it took time update.

                  ezgif.com-gif-maker.gif

                  My apologies for the delay, but I am still not 100% sure if I understand you correctly. But after looking at your scene and the screen cast, my understanding is that you are fighting here with priority issues. I.e.:

                  1. You select a IK-spline controller.
                  2. You press down the left mouse button and rotate the controller.
                  3. The IK-spline tag, and the IK-system is doing its work.
                  4. The IK model and the viewport update.
                  5. You stop rotating.
                  6. The Python tag kicks in.
                  7. The IK model and the viewport update again.

                  And you want to get rid of the second update to have a more convenient editing experience.

                  First of all, R20 is far out of scope of SDK and general user support. I do not even have an R20 license here. The general issue remains with all later versions of Cinema 4D but is less severe than with your screencast of R20. The core issues are here:

                  1. How the IK-spline updates, this not an SDK issue and seems to have been improved with R21 as I can reproduce the shading errors you have.
                  2. The IK evaluation and the Python tag execution priority.

                  Here is a R21 screencast, the updating-twice issue is quite subtle compared to your screen cast. I do not get the shading errors you get beyond 90°. When I rotate far enough, and the mesh starts to self-intersect, I will get them too. But this issue won't 'settle', i.e., won't change after the second update. prio_ik_snapping.gif

                  1. The main issue is a priority issue plus the quantization of the rotation you enabled, causing it to be very visible that things are updated twice.
                  2. You can enable "Frame Dependent" in the Python tag to mitigate the issue.
                    6b158d6b-283c-4bc2-9d7e-255e1b4010e6-image.png
                  3. Calling EventAdd() in your script is not necessary, the expression being called is already an event.

                  Cheers,
                  Ferdinand

                  The file: python_spline_ik.c4d
                  The result: ik_frame_dep.gif
                  The code:

                  import c4d
                  
                  # The inverse of your magic number
                  MAGIC_NUMBER = 1. / 3.783
                  
                  def main():
                      """
                      """
                      # Bail when there is no tag linked and when the tag is not of type Tcaikspline
                      tag = op[c4d.ID_USERDATA, 1]
                      if not isinstance(tag, c4d.BaseTag) or not tag.CheckType(1019862):
                          raise RuntimeError("Linked object is not an IK-Tag.")
                  
                      # Get the spline used by the IK tag.
                      spline = tag[c4d.ID_CA_IKSPLINE_TAG_SPLINE]
                      if not isinstance(spline, c4d.SplineObject):
                          raise RuntimeError("Linked object in IK-Tag is not a spline object.")
                  
                      # Do your magic number calculation.
                      helper = c4d.utils.SplineLengthData(spline)
                      helper.Init(spline)
                      newDepth = helper.GetLength() * MAGIC_NUMBER
                      helper.Free()
                  
                      # Update the two 'Depth' parameters.
                      for cid in (10004, 10014):
                          tag[cid] = newDepth
                  

                  MAXON SDK Specialist
                  developers.maxon.net

                  1 Reply Last reply Reply Quote 0
                  • JH23J
                    JH23
                    last edited by

                    Hello @jferdinand,
                    Apologies for the delay, I examined your example some time ago and I suspect that it does not solve my problem, activating "frame-dependent" causes the update to stop, and it is present in animation again, my intention is to completely remove that delay, both in editor and in animation.

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

                      Hey @jh23,

                      For me in R21.202, the delay is gone once you activate "Frame Dependent" parameter, both for editor interactions (see my previous posting) and an animation (see below). Am I overlooking here something?

                      0_1671203270269_ik_ani.gif

                      The large question is here probably what you would consider an animation. When you pile other expressions on top of this, which have incorrectly set up priorities, then you can run into the "needs-two-updates"-problem to evaluate a new state, regardless of Python being involved or not. I am not saying that this is "your fault", instead, I am just pointing out that the problem could lie somewhere else. It could also be that R20 behaves differently than R21, although this seems unlikely. As lined out before, R20 is out of scope of SDK support. The current official SDK support boundary is S26, and I currently have no access to a R20 license.

                      Cheers,
                      Ferdinand

                      MAXON SDK Specialist
                      developers.maxon.net

                      1 Reply Last reply Reply Quote 0
                      • JH23J
                        JH23
                        last edited by

                        I want to finish with this in case someone reads it. Years ago, I asked about the outdated methods when using these techniques. I tried to adjust the depth of the IK spline controls with the actual length of the spline itself. Today, I understand my mistake, as I was trying something that didn’t make logical sense. At the time, I thought it was the best option for what I was looking for.

                        In short, this was never a problem, and the low response time is normal because the length depends on the depth of the controls. I thought there would be a solution, but choosing this path was not useful.

                        In conclusion, what eventually satisfied my requirements was directly referencing the angles of the controls, meaning identifying how oriented each control is to another. I took this angle and used it as a factor to multiply by the depth. This model is much more logical and doesn’t have any flaws. At the time, I couldn’t think of a direct solution, but I didn’t want to leave this post like that. Thanks anyway, Ferdinand, for trying to help me.
                        Cheers
                        JH

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