Bsurfaces: Use context temp override to avoid deprecation #104486

Closed
Jorijn de Graaf wants to merge 4 commits from bonj/blender-addons:fix/bsurfaces into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
1 changed files with 24 additions and 13 deletions

View File

@ -4,8 +4,8 @@
bl_info = {
"name": "Bsurfaces GPL Edition",
"author": "Eclectiel, Vladimir Spivak (cwolf3d)",
"version": (1, 8, 1),
"blender": (2, 80, 0),
"version": (1, 8, 2),
"blender": (3, 2, 0),
"location": "View3D EditMode > Sidebar > Edit Tab",
"description": "Modeling and retopology tool",
"doc_url": "{BLENDER_MANUAL_URL}/addons/mesh/bsurfaces.html",
@ -1389,7 +1389,8 @@ class MESH_OT_SURFSK_add_surface(Operator):
self.is_crosshatch = False
# Delete all duplicates
bpy.ops.object.delete({"selected_objects": objects_to_delete})
with bpy.context.temp_override(selected_objects=objects_to_delete):
bpy.ops.object.delete('EXEC_REGION_WIN')
# If the main object has modifiers, turn their "viewport view status" to
# what it was before the forced deactivation above
@ -1610,7 +1611,8 @@ class MESH_OT_SURFSK_add_surface(Operator):
ob_surface.scale = (1.0, 1.0, 1.0)
# Delete final points temporal object
bpy.ops.object.delete({"selected_objects": [final_points_ob]})
with bpy.context.temp_override(selected_objects=[final_points_ob]):
bpy.ops.object.delete('EXEC_REGION_WIN')
# Delete isolated verts if there are any
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
@ -1749,7 +1751,8 @@ class MESH_OT_SURFSK_add_surface(Operator):
self.main_object.data.vertices[main_object_related_vert_idx].select = True
# Delete duplicated object
bpy.ops.object.delete({"selected_objects": [final_ob_duplicate]})
with bpy.context.temp_override(selected_objects=[final_ob_duplicate]):
bpy.ops.object.delete('EXEC_REGION_WIN')
# Join crosshatched surface and main object
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
@ -2539,7 +2542,8 @@ class MESH_OT_SURFSK_add_surface(Operator):
ob_simplified_curve[i].data.splines[0].bezier_points[t].co
# Delete the temporal curve
bpy.ops.object.delete({"selected_objects": [ob_simplified_curve[i]]})
with bpy.context.temp_override(selected_objects=[ob_simplified_curve[i]]):
bpy.ops.object.delete('EXEC_REGION_WIN')
# Get the coords of the points distributed along the sketched strokes,
# with proportions-U of the first selection
@ -3019,9 +3023,11 @@ class MESH_OT_SURFSK_add_surface(Operator):
surface_splines_parsed[len(surface_splines_parsed) - 1][i] = verts_middle_position_co
# Delete object with control points and object from grease pencil conversion
bpy.ops.object.delete({"selected_objects": [ob_ctrl_pts]})
with bpy.context.temp_override(selected_objects=[ob_ctrl_pts]):
bpy.ops.object.delete('EXEC_REGION_WIN')
bpy.ops.object.delete({"selected_objects": splines_U_objects})
with bpy.context.temp_override(selected_objects=splines_U_objects):
bpy.ops.object.delete('EXEC_REGION_WIN')
# Generate surface
@ -3176,7 +3182,8 @@ class MESH_OT_SURFSK_add_surface(Operator):
mat.roughness = 0.0
self.main_splines.data.materials.append(mat)
else:
bpy.ops.object.delete({"selected_objects": [self.main_splines]})
with bpy.context.temp_override(selected_objects=[self.main_splines]):
bpy.ops.object.delete('EXEC_REGION_WIN')
# Delete grease pencil strokes
if self.strokes_type == "GP_STROKES" and not self.stopping_errors:
@ -3275,7 +3282,8 @@ class MESH_OT_SURFSK_add_surface(Operator):
# executions of this operator, with the reserved names used here
for o in bpy.data.objects:
if o.name.find("SURFSKIO_") != -1:
bpy.ops.object.delete({"selected_objects": [o]})
with bpy.context.temp_override(selected_objects=[o]):
bpy.ops.object.delete('EXEC_REGION_WIN')
bpy.context.view_layer.objects.active = self.original_curve
@ -3413,7 +3421,8 @@ class MESH_OT_SURFSK_add_surface(Operator):
self.average_gp_segment_length = segments_lengths_sum / segments_count
# Delete temporary strokes curve object
bpy.ops.object.delete({"selected_objects": [self.temporary_curve]})
with bpy.context.temp_override(selected_objects=[self.temporary_curve]):
bpy.ops.object.delete('EXEC_REGION_WIN')
# Set again since "execute()" will turn it again to its initial value
self.execute(context)
@ -3434,7 +3443,8 @@ class MESH_OT_SURFSK_add_surface(Operator):
pass
bpy.ops.object.editmode_toggle('INVOKE_REGION_WIN')
bpy.ops.object.delete({"selected_objects": [self.original_curve]})
with bpy.context.temp_override(selected_objects=[self.original_curve]):
bpy.ops.object.delete('EXEC_REGION_WIN')
bpy.ops.object.editmode_toggle('INVOKE_REGION_WIN')
return {"FINISHED"}
@ -4062,7 +4072,8 @@ class CURVE_OT_SURFSK_reorder_splines(Operator):
bpy.context.object.name = curve_original_name
# Delete all unused objects
bpy.ops.object.delete({"selected_objects": objects_to_delete})
with bpy.context.temp_override(selected_objects=objects_to_delete):
bpy.ops.object.delete('EXEC_REGION_WIN')
bpy.ops.object.select_all('INVOKE_REGION_WIN', action='DESELECT')
bpy.data.objects[curve_original_name].select_set(True)