User:NBurn/2.80 Python API Changes
Eventually move to Reference/Release_Notes/2.80/Python_API
?
Update to embedded Python version (last checked: 2018-12-05)
-Python 3.5.3 (May 20 2017)
+Python 3.7.0 (Aug 26 2018)
Renamed lamp type
- The
Lamp
type from 2.7x has been replaced byLight
-bpy.types.Lamp
+bpy.types.Light
Matrix multiplication
- mathutils now uses the PEP 465 binary operator for multiplying matrices
import bpy
from mathutils import Matrix
mat_foo = Matrix(( (1, 2), (3, 4) ))
mat_bar = Matrix(( (11, 12), (13, 14) ))
mat_baz = mat_foo @ mat_bar # result: (37, 40), (85, 92)
BGL module (Over 700 entries removed, partial sample below)
-bgl.glBegin
-bgl.glBitmap
-bgl.glColor
-bgl.glColorMaterial
-bgl.glCopyPixels
-bgl.glDrawPixels
-bgl.glEnd
-bgl.glFog
-bgl.glIndex
-bgl.glLight
-bgl.glRect
-bgl.glRotate
-bgl.glScale
-bgl.glTexCoord
-bgl.glVertex
Other
-scene_update_pre
-scene_update_post
+depsgraph_update_pre
+depsgraph_update_post
-row = column.row(True)
+row = column.row(align=True)
-row.prop(self, "ctrl", "Ctrl", toggle=True)
+row.prop(self, "ctrl", text="Ctrl", toggle=True)
-col.label("Foo")
+col.label(text="Foo")
???
-space_data.use_occlude_geometry
+space_data.shading.show_xray
Additional resources:
- Updating Scripts from 2.7x (older version?)
- Blender 2.8x / Python, Proposed Changes
- T52599: Python API, changes to type registration in 2.8
- Blender 2.8 Python Meeting Notes
- 2.8: Addons UI
- Blender 2.8 Planning Update
Blender 2.80 API Changes
This section was backed up from:
https://en.blender.org/index.php/Dev:2.8/Source/LayersCollections/API-Changes
-context.scene.layers
+# no longer exists
-context.scene.objects
+context.render_layer.objects
-context.scene.objects.active
+context.render_layer.objects.active
-bpy.context.scene.objects.link()
+bpy.context.scene_collection.objects.link()
-bpy_extras.object_utils.object_data_add(context, obdata, operator=None, use_active_layer=True, name=None)
+bpy_extras.object_utils.object_data_add(context, obdata, operator=None, name=None)
-bpy.context.object.select
-bpy.context.object.select = True
-bpy.context.object.select = False
+bpy.context.object.select_get()
+bpy.context.object.select_set(action='SELECT')
+bpy.context.object.select_set(action='DESELECT')
-bpy.context.object.hide
+not bpy.context.object.visible_get()
-bpy.context.object.hide = False
+# no longer exists, use collection.hide instead
-AddObjectHelper.layers
rna_Scene_ray_cast requires a scene_layer argument.
Gotchas
scene_collection
If you copy context and override scene_layer, but not scene_collection what's going to be the override scene_collection?
It depends!
Is the original context.scene_collection linked (directly, or indirectly via nesting) into the overridden scene_layer? Then this is still the one you will get.
Is it not? In this case you get the active collection of the overridden scene_layer.