From fd26650439d101d7605e09e81b53b393ad2b5a6b Mon Sep 17 00:00:00 2001 From: Tristan Strathearn Date: Sun, 29 May 2022 16:52:57 +1000 Subject: [PATCH] fix: ensure the inset stage only begins if one or more faces have been selected when using the panel operator --- sketching/panel.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/sketching/panel.py b/sketching/panel.py index 0b4f336..379e4d7 100644 --- a/sketching/panel.py +++ b/sketching/panel.py @@ -94,7 +94,7 @@ def modal(self, context, event): self.dirty = True elif self.stage == 0 and self.key_confirm_alternative: - if self.stage == 0: + if self.has_valid_selection(context): self.isolate_geometry(context) self.stage = 1 self.dirty = True @@ -220,6 +220,13 @@ def inset_faces(self, faces): use_outset=False) + def has_valid_selection(self, context): + mesh = bmesh.from_edit_mesh(context.object.data) + selected_faces = len([f for f in mesh.faces if f.select]) + + return selected_faces > 0 + + def finish(self, context): bpy.ops.object.mode_set(mode='OBJECT') self.panel_obj.show_in_front = False