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.
Solved update error?
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
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.
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.
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] = Long /3.783 # = control depth 1 iKsplinetag op[c4d.ID_USERDATA,1] = Long /3.783 # = 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
Thank you for your update. I will take a look next week, as I won't have the time tomorrow, Friday.
My apologies, I forgot your thread in the 2023.1 release hectic, I will have a look next thing tomorrow morning.
@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.
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.:
- You select a IK-spline controller.
- You press down the left mouse button and rotate the controller.
- The IK-spline tag, and the IK-system is doing its work.
- The IK model and the viewport update.
- You stop rotating.
- The Python tag kicks in.
- 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:
- 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.
- 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.
- 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.
- You can enable "Frame Dependent" in the Python tag to mitigate the issue.
EventAdd()in your script is not necessary, the expression being called is already an event.
The file: python_spline_ik.c4d
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
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.
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?
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