1
$\begingroup$

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
        )
$\endgroup$
5
  • 3
    $\begingroup$ 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). $\endgroup$
    – batFINGER
    May 24, 2021 at 17:46
  • $\begingroup$ 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. $\endgroup$
    – Raja
    May 24, 2021 at 17:48
  • 1
    $\begingroup$ See my answer here blender.stackexchange.com/questions/204268/… same applies to image strip... ditch the operator $\endgroup$
    – batFINGER
    May 24, 2021 at 17:49
  • $\begingroup$ Thanks so much I really appreciate your response! I'll check it out and let you know how it goes :) $\endgroup$
    – Raja
    May 24, 2021 at 17:51
  • $\begingroup$ Wow thanks so much @batFINGER, it works perfectly! I'll write this as an answer. Thanks again :) $\endgroup$
    – Raja
    May 24, 2021 at 19:45

1 Answer 1

1
$\begingroup$

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.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .