I have a script.
import bpy
obj = bpy.context.object
for action in bpy.data.actions:
obj.animation_data.action = bpy.data.actions.get(action.name)
bpy.context.scene.render.filepath = './render/' + action.name+'_'
bpy.ops.render.render(use_viewport = True, write_still=True, animation=True)
and I try run it by command line:
blender -b 01_a_camera.blend -P render_action.py
I got an error mes:
Read prefs: /home/vietnam/.config/blender/2.79/config/userpref.blend
found bundled python: /snap/blender/20/2.79/python
ENTERING RIGIFY LEGACY
Read blend: /home/vietnam/Downloads/01_a_camera.blend
Traceback (most recent call last):
File "/home/vietnam/Downloads/render_action.py", line 4, in <module>
obj.animation_data.action = bpy.data.actions.get(action.name)
AttributeError: 'NoneType' object has no attribute 'action'
Blender quit
But when I run that script by console or by Text editor on blender file, It works normally. What is the problem here?