from 2.7 to 2.8

How to link a new object to a scene in Blender 2.80 Python API

In Blender 2.79 Python API we can add a new object to a scene with:

If we try to do this in Blender 2.80, it throws an error:

‘bpy_prop_collection’ object has no attribute ‘link’

In Blender 2.80 API new objects mast be linked not to the scene, but to the scene collections:

To link a new object to the active scene collection:

To link a new object to the collection by its name:

 

15 changes that you need to know when migrating from Blender 2.79 to Blender 2.80

  1. Object selection

2.79: selecting with the right mouse button
2.80: left-click selection

  1. T-panel

2.79: called by pressing the “t” key
2.80: it’s gone, functions moved to the main menu and to the context right-click menu

  1. Deselection

2.79: “a” – select all and deselect all
2.80: “a” – select all, “a – a” or “alt+a” – deselect all

Class naming conventions in Blender 2.8 Python API

In Blender 2.8 API the requirements for the class and their identifiers naming are becoming tougher. The class name must match the following convention:

Where the {SEPARATOR} is two letters denoting the class belonging to a certain type (from which type the class is inherited):

  • HT – Header
  • MT – Menu
  • OT – Operator
  • PT – Panel
  • UL – UI list

The class identifier “bl_idname” mast match the class name.

Changes in add-ons registration through the API in Blender 2.8

Add-on registration and removing were made with the “Window manager” (wm) in Blender 2.7 Python API:

In Blender 2.8 API add-on operators moved to the “preferences”:

 

3D Cursor location in Blender 2.8 Python API

3D-cursor location property

in Blender 2.8 API moved to “cursor” object

When trying to get the cursor location through the “context.scene.cursor_location” Blender throws an error:

‘Scene’ object has no attribute ‘cursor_location’

Matrix, vector and quaternion multiplication in Blender 2.8 Python API

In Blender 2.7 the “*” (star) operator is used in the matrix, vector, and quaternion multiplication. In Blender 2.8 it is replaced with the “@” (at) operator.

If the “*” operator is used in vector, matrix or quaternion multiplication in Blender 2.8 it throws an error:

Element-wise multiplication: not supported between ‘Matrix’ and ‘Matrix’ types

Proper use of the “@” operator:

 

Accessing the pivot point type in Blender 2.8 Python API

The “pivot_point” property from Blender 2.7

in Blender 2.8 API moved to: