Loading
Blender 2.80
Upgrading to Blender 2.80
Blender 2.80 is coming up, and the Scripting for Artists series was made for 2.79. Fortunately there is only a little you need to change to make the techniques work in the new Blender version.
Selecting and Hiding
Selecting an object in Blender 2.79 is as easy as setting a property: ob.select = True
. Blender 2.80 has a more elaborate view layer system, and an object can be selected in one view layer and not selected in another, so there is no more single "selected" attribute of an object. Instead, you can use ob.select_set(True)
to select the object in the active view layer, or ob.select_set(True, the_view_layer)
if you want to select it in a specific one. To retrieve the selection state, use is_selected = ob.select_get()
for the selection state in the active view layer, or is_selected = ob.select_get(the_view_layer)
if you want to retrieve it for a specific view layer.
Hiding and un-hiding an object follows the same approach, replacing the ob.hide
property with ob.hide_get()
and ob.hide_set()
functions.
Size of New Objects
The mesh object creation operators, like primitive_ico_sphere_add()
, used to take a radius
parameter to indicate the size of the mesh. In Blender 2.80 this has been replaced by size
. There is a factor 2 difference between radius
and size
(the latter could be called the diameter), so for example replace bpy.ops.mesh.primitive_ico_sphere_add(radius=0.2)
with …primitive_ico_sphere_add(size=0.4)
.
Matrix Multiplication
In Tech 4: Rendering from 'all' angles we use vcoord = placement_ob.matrix_world * vert.co
to perform a matrix multiplication. In Blender 2.80 this should use the @
operator, so it becomes vcoord = placement_ob.matrix_world @ vert.co
.
Documentation
There is new Python API documentation for the upcoming 2.80 release that's now on a link that'll always be for the "upcoming version". It is not updated every day, but generally it's accurate. Of course there is also API documentation for the last release, which currently is 2.79b.
Most backward-incompatible changes in the Python API introduced in 2.80 are also documented in the 2.80 release notes.