Skip to content

Commit

Permalink
fix: ensure the inset stage only begins if one or more faces have bee…
Browse files Browse the repository at this point in the history
…n selected when using the panel operator
  • Loading branch information
tristan-hm committed May 29, 2022
1 parent d27a8ab commit fd26650
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion sketching/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit fd26650

Please sign in to comment.