0
$\begingroup$

In blender 2.82 I want to decimate all the f-curves in active action, how can I override the context to make the script work with Animation Nodes Script Node?

import bpy
if decimate:
    bpy.context.area.type = 'GRAPH_EDITOR'
    bpy.ops.graph.decimate(mode='RATIO', remove_ratio=0.92)
$\endgroup$
0
$\begingroup$

Like this:

import bpy  
def simplify_fcurves():
    C=bpy.context
    old_area_type = C.area.type
    C.area.type='GRAPH_EDITOR'
    bpy.ops.graph.decimate(mode='ERROR', remove_ratio=0.698113, remove_error_margin=0.5)
    C.area.type=old_area_type    
simplify_fcurves()
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.