0
$\begingroup$

I am facing a problem when trying to run my script for Fcurve smoothing form terminal. I have read that some operations are not supported when running Blender in the background. Moreover, bpy.context.area must be run in Blender, otherwise it will return NonType error if I run the script from terminal. My questions is: Is there any solution for that? I need to smooth my animations from terminal since this is a part of my project. Any help will be appreciated. Thanks

import os
import sys

import bpy

# delete the cube

if bpy.context.object.mode == “EDIT”:
    bpy.ops.object.mode_set(mode=“OBJECT”)

bpy.ops.object.select_all(action=“DESELECT”)

if “Cube” in bpy.data.objects:
    bpy.data.objects[“Cube”].select_set(True)
    bpy.ops.object.delete()


# import file
bpy.ops.import_scene.fbx(
    filepath=“fbx_input.fbx”,
    axis_forward=“-Z”,
    axis_up=“Y”,
)

# Fcurve smoothing
bpy.context.area.ui_type = “FCURVES”
bpy.ops.graph.smooth()

# Export as FBX
bpy.ops.export_scene.fbx(
    filepath=“fbx_smoothed_output.fbx”,
    axis_forward=“-Z”,
    axis_up=“-X”,
)
$\endgroup$

Your Answer

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

Browse other questions tagged or ask your own question.