That's exactly the solution! wrapping the prev and next keyframe locations in math.ceil() and math.floor() Thank you very much for solving this problem that I had not solved for a long time. A success!
El viernes, 10 de mayo de 2024 a las 19:25:36 UTC-3, Justin Israel escribió: > I had a quick look at this, and what it seems to be doing is encountering > a rounding issue when you are trying to set keyframes before and after the > current time. When you have a mid-point that is not an even number, such as > 17.5 for the previous keyframe and 32.5 for the next keyframe, and you pass > those float values to setKeyframe(), it is going to round them both up to > the next whole number. that is going to result in the left side being a > closer distance from your current time and the right side being > farther away. > If your goal is to make them an even distance from the current time, then > a possible solution is to always round the left side up, and always round > the right side down. > This example is wrapping the prev and next keyframe locations in > math.ceil() and math.floor(), respectively: > https://gist.github.com/justinfx/697f5c7a3453848b44f1ed0f6de3d9bd > > Justin > > > On Fri, May 3, 2024 at 6:14 AM Darwin Giordano <dg3...@gmail.com> wrote: > >> With chatgpt I managed to make a script that adds animation keys between >> the previous and next key based on the keyframe of the current timeline >> where the user is located. >> >> It happens to add keyframes correctly until at a given time when >> approaching the current timeline key then the key creation is not accurate, >> apparently it fails in 1 frame the distance where it should add the keys. I >> don't know how to correct it. >> [image: keys.gif] >> Code: >> https://gist.github.com/Fenixdg3duy/56eae81e3064e5929938168c53d2cd88 >> >> anyone who can shed light on this issue as to why the keys do not keep >> the distance to a point close to the current timeline? >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Python Programming for Autodesk Maya" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to python_inside_m...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/python_inside_maya/8ccb8b62-1b9c-4da4-85f6-9e99d8743ecbn%40googlegroups.com >> >> <https://groups.google.com/d/msgid/python_inside_maya/8ccb8b62-1b9c-4da4-85f6-9e99d8743ecbn%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> > -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/609e27be-c4a7-4e24-9a25-c4f256409af8n%40googlegroups.com.