From 54d50be586a59feed3375a5edaff9f58ec853c1a Mon Sep 17 00:00:00 2001 From: bonjorno7 Date: Tue, 14 Mar 2023 21:22:39 +0100 Subject: [PATCH 1/2] Fix #104484: Bsurfaces addon stopped working Passing context override to operators is deprecated in favor of Context.temp_override. I used EXEC_REGION_WIN to be consistent with how the rest of the addon calls operators. --- mesh_bsurfaces.py | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/mesh_bsurfaces.py b/mesh_bsurfaces.py index 3bb433e04..077af818a 100644 --- a/mesh_bsurfaces.py +++ b/mesh_bsurfaces.py @@ -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) -- 2.30.2 From 51d715db30abc9d0ca3b59670d828a6f7b708199 Mon Sep 17 00:00:00 2001 From: bonjorno7 Date: Tue, 14 Mar 2023 21:37:56 +0100 Subject: [PATCH 2/2] Bsurfaces: Bump version and Blender version Context.temp_override was introduced in Blender 3.2, so I'm making that the minimum Blender version. I'll also bump the addon version, because changes were made and it'd be confusing not to change the version too then. --- mesh_bsurfaces.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mesh_bsurfaces.py b/mesh_bsurfaces.py index 077af818a..db6cc243b 100644 --- a/mesh_bsurfaces.py +++ b/mesh_bsurfaces.py @@ -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", -- 2.30.2