1

My code runs fine when I run the script directly in blender. However if run the file headless in the terminal I get this error and the animation renders the default cube instead of my animation:

'NoneType' object has no attribute 'ui_type'

Here is my CLI command:

'/Applications/Blender.app/Contents/MacOS/Blender -b /Users/myname/Desktop/folder/videoRender.blend -a"

Blender text editor code:

import bpy, sys, os

bpy.context.area.ui_type = 'SEQUENCE_EDITOR'

#create image sequences and import screens of there are more than one file if (len(files) == 1):

# set duration to 300
duration = 300

for index in range(5):
    filesFolder = folder + "/" + str((index+1)) + '/renderedFiles/'
    bpy.ops.sequencer.image_strip_add(
        directory=filesFolder, 
        files=files[1], 
        show_multiview=False,
        frame_start= (filesCount * index), 
        frame_end=filesCount * index, 
        channel=5
    )

Raja
  • 185
  • 7
  • 3
    Been asked often before. Background mode is also known as "headless" because it loads no UI. Hence there is no context area (it's None hence the error). – batFINGER May 24 '21 at 17:46
  • Hey @batFINGER, I understand however do you know how I can change the context area in headless mode please? I can't find a solution after looking through here. – Raja May 24 '21 at 17:48
  • 1
    See my answer here https://blender.stackexchange.com/questions/204268/simple-python-script-to-stitch-images-into-movie-failing-with-incorrect-context same applies to image strip... ditch the operator – batFINGER May 24 '21 at 17:49
  • Thanks so much I really appreciate your response! I'll check it out and let you know how it goes :) – Raja May 24 '21 at 17:51
  • Wow thanks so much @batFINGER, it works perfectly! I'll write this as an answer. Thanks again :) – Raja May 24 '21 at 19:45

1 Answers1

1

Thanks to @batFINGER, his solution to ditch the operator worked! Here's the answer: Simple python script to stitch images into movie failing with incorrect context.

Raja
  • 185
  • 7