diff options
author | Alan Odom <clockmender@icloud.com> | 2020-01-13 19:34:56 +0300 |
---|---|---|
committer | Rune Morling <ermo.blender.org@spammesenseless.net> | 2020-01-15 00:31:09 +0300 |
commit | 2eb5ee12cef8cc8500042c46905c64f4d12575cf (patch) | |
tree | 949d3b8a46f6578994a50840ff73a80a3a21f794 /precision_drawing_tools | |
parent | 1f39f4234a24c57ab35f918c1c23a8439dbc1f1c (diff) |
PDT: Fix Command Line selection-related bug
Fix bug where if selection was not made by cursor select, an error occurs in
placing cursor, pivot point, adding edges by percentage, etc.
Diffstat (limited to 'precision_drawing_tools')
-rw-r--r-- | precision_drawing_tools/pdt_command.py | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/precision_drawing_tools/pdt_command.py b/precision_drawing_tools/pdt_command.py index eb45f73a..2b215fb1 100644 --- a/precision_drawing_tools/pdt_command.py +++ b/precision_drawing_tools/pdt_command.py @@ -273,6 +273,16 @@ def command_run(self, context): pg.error = f"'{mode}' {PDT_ERR_NON_VALID} '{oper}'" context.window_manager.popup_menu(oops, title="Error", icon="ERROR") return + if mode in {"d","i"}: + if len(bm.select_history) == 0: + if len(bm.verts) == 0: + pg.error = PDT_ERR_NO_SEL_GEOM + context.window_manager.popup_menu(oops, title="Error", icon="ERROR") + return + else: + verts = bm.verts + else: + verts = bm.select_history # Absolute/Global Coordinates if mode == "a": if len(vals) != 3: @@ -300,10 +310,10 @@ def command_run(self, context): if obj.mode == "EDIT": if oper == "C": scene.cursor.location = ( - bm.select_history[-1].co + obj_loc + vector_delta + verts[-1].co + obj_loc + vector_delta ) else: - pg.pivot_loc = bm.select_history[-1].co + obj_loc + vector_delta + pg.pivot_loc = verts[-1].co + obj_loc + vector_delta elif obj.mode == "OBJECT": if oper == "C": scene.cursor.location = obj_loc + vector_delta @@ -325,10 +335,10 @@ def command_run(self, context): if obj.mode == "EDIT": if oper == "C": scene.cursor.location = ( - bm.select_history[-1].co + obj_loc + vector_delta + verts[-1].co + obj_loc + vector_delta ) else: - pg.pivot_loc = bm.select_history[-1].co + obj_loc + vector_delta + pg.pivot_loc = verts[-1].co + obj_loc + vector_delta elif obj.mode == "OBJECT": if oper == "C": scene.cursor.location = obj_loc + vector_delta @@ -445,6 +455,16 @@ def command_run(self, context): pg.error = PDT_ERR_ADDVEDIT context.window_manager.popup_menu(oops, title="Error", icon="ERROR") return + if mode in {"d","i"}: + if len(bm.select_history) == 0: + if len(bm.verts) == 0: + pg.error = PDT_ERR_NO_SEL_GEOM + context.window_manager.popup_menu(oops, title="Error", icon="ERROR") + return + else: + verts = bm.verts + else: + verts = bm.select_history # Absolute/Global Coordinates if mode == "a": if len(vals) != 3: @@ -466,7 +486,7 @@ def command_run(self, context): context.window_manager.popup_menu(oops, title="Error", icon="ERROR") return vector_delta = Vector((float(vals[0]), float(vals[1]), float(vals[2]))) - vNew = bm.select_history[-1].co + vector_delta + vNew = verts[-1].co + vector_delta nVert = bm.verts.new(vNew) for v in [v for v in bm.verts if v.select]: v.select_set(False) @@ -480,7 +500,7 @@ def command_run(self, context): context.window_manager.popup_menu(oops, title="Error", icon="ERROR") return vector_delta = disAng(vals, flip_a, plane, scene) - vNew = bm.select_history[-1].co + vector_delta + vNew = verts[-1].co + vector_delta nVert = bm.verts.new(vNew) for v in [v for v in bm.verts if v.select]: v.select_set(False) @@ -693,7 +713,7 @@ def command_run(self, context): # Percent Options elif mode == "p": vector_delta = getPercent(obj, flip_p, float(vals[0]), oper, scene) - verts = [v for v in bm.verts if v.select] + verts = [v for v in bm.verts if v.select].copy() if len(verts) == 0: pg.error = PDT_ERR_NO_SEL_GEOM context.window_manager.popup_menu(oops, title="Error", icon="ERROR") @@ -704,7 +724,7 @@ def command_run(self, context): bm.edges.new([v, nVert]) v.select_set(False) else: - bm.edges.new([bm.select_history[-1], nVert]) + bm.edges.new([verts[-1], nVert]) nVert.select_set(True) bmesh.update_edit_mesh(obj.data) bm.select_history.clear() |