Changing viewport anti-aliasing through code

Hi!

I’m currently working on a script to help me optimize my viewport for better performance.
One way is changing the viewport aa. I have already found the line of code in which I can reference aa:

import bpy

bpy.types.PreferencesSystem.viewport_aa

But I can’t figure out how to set a variable. My best guess was:

import bpy

bpy.types.PreferencesSystem.viewport_aa = "FXAA"

When I run that script, I don’t get an error but nothing happens either. It’s probably something simple I’m missing.

Thanks in advance!

If it helps: Blender API help link

bpy.types isn’t meant for changing values, instead it stores the internal “types” of every property in Blender.

Instead, you should use bpy.data or bpy.context to access and modify properties. In your case, to change the current scene’s anti-aliasing, you should use:

bpy.context.scene.display.viewport_aa = "FXAA"

I would recommend watching some tutorials to get a feel for how the API works, these are pretty good:

Hope that helps :slight_smile:

1 Like

Thanks for answering, will try this later!
I am actually following the playlist that you linked, seems like I’ve made a good choice then

1 Like