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.

View File

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