Reference/Release Notes/2.80/Python API

From Blender Developer Wiki
Jump to: navigation, search

Blender 2.80: Python API Changes

Blender 2.80 is an API breaking release. Addons and scripts will need to be updated to run on 2.80, both to handle the new features and adapt to changes to make the API more consistent and reliable.

Please note: The current Python API for Blender 2.80 is under active development and considered unstable (it may change at any time). It is generally recommended add-on authors wait until after the 2.80 Beta is released (planned for late October or November) to update their code.

Addon API

Module and class registration has been changed, all addons need to be updated to handle these.

Scene and Object API

The new view layers, collections, selection and dependency graph systems require updates to scripts.

Mesh API

A few changes were made to the Mesh API, mainly the data structures for triangles tessellation.

User Interface API

New toolbar, property layouts and icons require addon updates.

Draw API

Blender was upgraded to the OpenGL core profile, which affects addons.

Helper Modules

Various helper Python modules have been added, removed or changed.

Keyword Only Arguments

All keyword arguments must be given as keywords and cannot be passed by position:

2.7x

context.scene.frame_set(10, 0.25)
noise.noise(position, noise.types.BLENDER)

2.8x

context.scene.frame_set(10, subframe=0.25)
noise.noise(position, noise_basis='BLENDER')

Matrix Multiplication

Matrix multiplication previously used *, scripts should now use @ for multiplication (per PEP 465). This applies to:

  • Vector * Vector
  • Quaternion * Vector
  • Matrix * Vector
  • Vector * Matrix
  • Matrix * Matrix

Note: In the future * will be used for element-wise multiplication

2.7x:

mat = Matrix()
vec = Vector()
result = mat * vec

2.8x:

mat = Matrix()
vec = Vector()
result = mat @ vec

Using the 2.7x syntax in 2.80 or later will result in this error:

TypeError: Element-wise multiplication: not supported between 'xxx' and 'yyy' types

Operator Updates

Removed:
object.select_by_layer


Replaced:
view3d.viewnumpad          (use view3d.view_axis or view3d.view_camera instead)

Property Updates

Replaced:
SpaceView3D.viewport_shader  ->  SpaceView3D.shading.type