curve simplification script (2.5)

Hey, today I used Simplify F-Curves. It’s very useful!

I have to tell you that it throws some errors by changing (maybe so much) Error threshold value:

Array iterator out of range: FCurve_keyframe_points_lookup_int (index 33)
Traceback (most recent call last):
  File "/home/mario/bl/2.75a/2.75/scripts/addons/curve_simplify.py", line 459, in execute
    fcurves_simplify(context, obj, options, self.fcurves)
  File "/home/mario/bl/2.75a/2.75/scripts/addons/curve_simplify.py", line 353, in fcurves_simplify
    fcurve_sel[fcurve_i].keyframe_points.remove(fcurve_sel[fcurve_i].keyframe_points[i])
IndexError: bpy_prop_collection[index]: index 33 out of range, size 33

This error is shown… and, after moving the mouse (cancelling the info box), the error appears again and again… for a while, till it the value arrives to the final value that I set (in recent test, more than 1000, sorry!)

Maybe this is not a script bug, but maybe it should have “try” and “except” to catch the error and explain it (by you).

Thank you for the addon!

Thanks so much for this script TestScreenings, it gives very nice results!

It was not working with shape keys animation, but I fixed this directly, and thought this may interest other people and maybe would be nice to include directly in next blender release.
So please find the adjusted script enclosed

curve_simplify.zip (5.16 KB)

Cheers! :smiley:

I think I’ve found a problem with curve simplify but it doesn’t happen every time.
I caught one instance where it did happen and have added it as an attachment.
The original curve was generated by my gt2-spline.py script, which calls curve simplify.
I wasn’t able to upload my gt2-spline.py, maybe you can suggest a way if you need it.

Attachments

simplify.blend (652 KB)

I know this is an old thread but one quick question. Should the “error threshold” setting be looked at as a percentage of the keyframes that will be deleted? Or as a percentage of the keyframes that will remain AFTER others are deleted? Basically the words " error threshold’ do not have a very clear meaning to a non programmer or mathmatician.

It doesn’t matter much, the word “threshold” is what’s key here, adjust it until it gives the desired result.
The only way it would matter is if you generated the mesh yourself and knew the exact percentage needed by formula.
Speaking of which, I moved on to generating my meshes with c++ - for example how gravity cancels when two black holes approach, distorting their event horizons.
Blender can’t do these kinds of implicit surfaces (yet) much less in sort-of real time.

Philius Thanks for your response but this plugin works on curves and fcurves. Not meshes.

@SHABA1 yes this is an old thread, I think my problems went away with subsequent blender versions.
Take a look at the source code, python’s not too difficult to learn, then you’ll know how the threshold is calculated.
When I discovered how simple the “.off” file format is, it was a breeze to generate curves and meshes, and indeed the first event-horizon program generates a curve.
Sorry if I forgot the topic of this thread, but if you’re generating a curve, it’s best to generate it correctly rather than trying to fix it with a plug-in.