7
$\begingroup$

I'm trying to make a script and I'm having trouble with this line:

bpy.data.scenes[0].render.file_format = 'PNG'

And it prints this error:

AttributeError: 'RenderSettings' object has no attribute 'fileformat'

Of course it's no big issue to click the mouse and set it, but I want to find out why it doesn't work. When I hover over the File Format menu in the render settings I see this:

bpy.data.scenes["Scene"] ... file_format

I noticed that there are a few other commands which show "..." in the attribute's "path". I checked out the docs, it doesn't say that file_format is deprecated. I'm using the latest version and Blender's default renderer.

Any idea why it doesn't work?

$\endgroup$

1 Answer 1

6
$\begingroup$

It seems that the path you tried to use only exists in a context for UI elements, from properties_render.py:

def draw(self, context):
    layout = self.layout

    rd = context.scene.render
    image_settings = rd.image_settings
    file_format = image_settings.file_format

    layout.prop(rd, "filepath", text="")

In a script you could use something like:

bpy.data.scenes[0].render.image_settings.file_format="PNG";
$\endgroup$
0

You must log in to answer this question.

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