Blender object does not have any modifiers in Python script

Viewed 23

I am writing a Python script for Blender 3.1 to set the "Line Art" modifier camera to the next camera in the scene to do a render.

The issue is my script cannot find any modifiers for my Stroke object:

import bpy
import os

path_dir = bpy.context.scene.render.filepath

stroke = bpy.context.scene.objects.get('Stroke')

if not stroke:
    raise ValueError("Object with name Stroke not found")

if len(stroke.modifiers) == 0:
    raise ValueError("Stroke has no modifiers")

Error:

"render multiple cameras with line art.py", line 14, in <module>
ValueError: Stroke has no modifiers

It's definitely there:

enter image description here

I have tried

  • forcing into object mode
  • using the selected object instead of searching for it
  • forcing the object to be selected

What's wrong?

1 Answers
Related