This message outlines the specific updates made to a Blender script, highlighting the adaptations to the latest recommended practices by Blender's API. The changes are detailed line by line, reflecting the modifications from the previous version to the newer one.
Object Selection and Deletion
Before:
bpy.data.objects['Cube'].select = True
After:
bpy.data.objects['Cube'].select_set(True)
This change updates the method for selecting objects to select_set(True), replacing the deprecated .select property. It ensures compatibility with newer versions of Blender.
Active Object Setting
Before:
scn.objects.active = cam_ob
After:
bpy.context.view_layer.objects.active = cam_ob
The method for setting the active object has been updated to use bpy.context.view_layer.objects.active, aligning the script with changes in Blender's API for better compatibility.
Render passes are now directly set on bpy.context.view_layer instead of using scn.render.layers["RenderLayer"]. This aligns the script with Blender API changes regarding render layer and pass management.
Global Object Selection and Active Object Reset
Before:
for ob in bpy.data.objects.values():
ob.select = False
bpy.context.scene.objects.active = None
After:
for ob in bpy.data.objects.values():
ob.select_set(False)
bpy.context.view_layer.objects.active = None
These modifications also reflect the updated methods select_set(False) for global object selection and resetting the active object using the current view_layer. This ensures better integration with Blender's layering system and avoids deprecated methods.
Scene Update
Implicit Before:
scene.update()
After:
bpy.context.view_layer.update()
Although not explicitly shown in the provided snippets, the implicit replacement by bpy.context.view_layer.update() in the new version complies with recommended practices for refreshing the scene and state after programmatic changes in Blender.
These updates make the script compatible with recent versions of Blender, aligning it with current recommended practices for interacting with the Blender API.
Blender Script API Changes Documentation
This message outlines the specific updates made to a Blender script, highlighting the adaptations to the latest recommended practices by Blender's API. The changes are detailed line by line, reflecting the modifications from the previous version to the newer one.
Object Selection and Deletion
Before:
After:
This change updates the method for selecting objects to
select_set(True)
, replacing the deprecated.select
property. It ensures compatibility with newer versions of Blender.Active Object Setting
Before:
After:
The method for setting the active object has been updated to use
bpy.context.view_layer.objects.active
, aligning the script with changes in Blender's API for better compatibility.Render Passes Update
Before:
After:
Render passes are now directly set on
bpy.context.view_layer
instead of usingscn.render.layers["RenderLayer"]
. This aligns the script with Blender API changes regarding render layer and pass management.Global Object Selection and Active Object Reset
Before:
After:
These modifications also reflect the updated methods
select_set(False)
for global object selection and resetting the active object using the currentview_layer
. This ensures better integration with Blender's layering system and avoids deprecated methods.Scene Update
Implicit Before:
After:
Although not explicitly shown in the provided snippets, the implicit replacement by
bpy.context.view_layer.update()
in the new version complies with recommended practices for refreshing the scene and state after programmatic changes in Blender.These updates make the script compatible with recent versions of Blender, aligning it with current recommended practices for interacting with the Blender API.