diff options
author | Alan Odom <clockmender@icloud.com> | 2020-02-05 15:06:08 +0300 |
---|---|---|
committer | Rune Morling <ermo.blender.org@spammesenseless.net> | 2020-02-05 15:42:04 +0300 |
commit | 90b46441d5e56777b871fdddcae4392379687b1d (patch) | |
tree | 3a84740e8e88eb8d3a91f44615648c4991539e56 /precision_drawing_tools | |
parent | b652724b15d99f91612ca2d55a1167a4b73ade12 (diff) |
PDT: Various improvements to help avoid user error
In certain circumstances, where the user has unwisely set inappropriate inputs,
modes of operation, or other settings, some errors were not trapped. This fixes those
making the system more "User Proof". A new exception was added if the user works
in an inappropriate feature setting, like Face mode when Vertex mode is required.
Diffstat (limited to 'precision_drawing_tools')
-rw-r--r-- | precision_drawing_tools/pdt_command.py | 14 | ||||
-rw-r--r-- | precision_drawing_tools/pdt_command_functions.py | 6 | ||||
-rw-r--r-- | precision_drawing_tools/pdt_exception.py | 4 |
3 files changed, 18 insertions, 6 deletions
diff --git a/precision_drawing_tools/pdt_command.py b/precision_drawing_tools/pdt_command.py index dbcb76c2..8843b4ea 100644 --- a/precision_drawing_tools/pdt_command.py +++ b/precision_drawing_tools/pdt_command.py @@ -63,6 +63,7 @@ from .pdt_msg_strings import ( PDT_ERR_INT_LINES, PDT_LAB_PLANE, PDT_ERR_NO_ACT_OBJ, + PDT_ERR_VERT_MODE, ) from .pdt_bix import add_line_to_bisection from .pdt_etof import extend_vertex @@ -76,6 +77,7 @@ PDT_ObjectModeError = pdt_exception.ObjectModeError PDT_MathsError = pdt_exception.MathsError PDT_IntersectionError = pdt_exception.IntersectionError PDT_NoObjectError = pdt_exception.NoObjectError +PDT_FeatureError = pdt_exception.FeatureError class PDT_OT_CommandReRun(Operator): @@ -438,10 +440,15 @@ def command_parse(context): obj_loc = Vector((0,0,0)) verts = [] + if mode_sel == 'REL' and operation not in {"C", "P"}: + pg.select = 'SEL' + mode_sel = 'SEL' + if mode == "a" and operation not in {"C", "P"}: # Place new Vetex, or Extrude Vertices by Absolute Coords. if mode_sel == 'REL': pg.select = 'SEL' + mode_sel = 'SEL' if obj is not None: if obj.mode == "EDIT": bm = bmesh.from_edit_mesh(obj.data) @@ -456,7 +463,6 @@ def command_parse(context): context.window_manager.popup_menu(oops, title="Error", icon="ERROR") raise PDT_NoObjectError - if mode_sel == 'SEL' and mode not in {"a"}: # All other options except Cursor or Pivot by Absolute # These options require no object, etc. @@ -643,6 +649,10 @@ def add_new_vertex(context, pg, operation, mode, obj, bm, verts, values): pg.error = PDT_ERR_ADDVEDIT context.window_manager.popup_menu(oops, title="Error", icon="ERROR") raise PDT_SelectionError + if not isinstance(verts[0], bmesh.types.BMVert): + pg.error = PDT_ERR_VERT_MODE + context.window_manager.popup_menu(oops, title="Error", icon="ERROR") + raise PDT_FeatureError # Absolute/Global Coordinates if mode == "a": try: @@ -862,7 +872,6 @@ def extrude_vertices(context, pg, operation, mode, obj, obj_loc, bm, verts, valu new_vertex.select_set(True) bmesh.update_edit_mesh(obj.data) - bm.select_history.clear() def extrude_geometry(context, pg, operation, mode, obj, bm, values): @@ -968,7 +977,6 @@ def duplicate_geometry(context, pg, operation, mode, obj, bm, values): bmesh.ops.translate(bm, verts=verts_dupe, vec=vector_delta) update_sel(bm, verts_dupe, edges_dupe, faces_dupe) bmesh.update_edit_mesh(obj.data) - bm.select_history.clear() def fillet_geometry(context, pg, mode, obj, bm, verts, values): diff --git a/precision_drawing_tools/pdt_command_functions.py b/precision_drawing_tools/pdt_command_functions.py index d1203602..e499a71a 100644 --- a/precision_drawing_tools/pdt_command_functions.py +++ b/precision_drawing_tools/pdt_command_functions.py @@ -151,7 +151,7 @@ def placement_normal(context, operation): if vector_a is None: pg.error = PDT_ERR_VERT_MODE context.window_manager.popup_menu(oops, title="Error", icon="ERROR") - raise PDT_InvalidVector + raise PDT_FeatureError else: pg.error = f"{PDT_ERR_SEL_3_VERTIO} {len(bm.select_history)})" context.window_manager.popup_menu(oops, title="Error", icon="ERROR") @@ -566,7 +566,7 @@ def set_angle_distance_two(context): if vector_a is None: pg.error = PDT_ERR_VERT_MODE context.window_manager.popup_menu(oops, title="Error", icon="ERROR") - raise PDT_InvalidVector + raise PDT_FeatureError else: pg.error = f"{PDT_ERR_SEL_2_VERTIO} {len(bm.select_history)})" context.window_manager.popup_menu(oops, title="Error", icon="ERROR") @@ -645,7 +645,7 @@ def set_angle_distance_three(context): if vector_a is None: pg.error = PDT_ERR_VERT_MODE context.window_manager.popup_menu(oops, title="Error", icon="ERROR") - raise PDT_InvalidVector + raise PDT_FeatureError else: pg.error = f"{PDT_ERR_SEL_3_VERTIO} {len(bm.select_history)})" context.window_manager.popup_menu(oops, title="Error", icon="ERROR") diff --git a/precision_drawing_tools/pdt_exception.py b/precision_drawing_tools/pdt_exception.py index dd2aea4d..d0dc157a 100644 --- a/precision_drawing_tools/pdt_exception.py +++ b/precision_drawing_tools/pdt_exception.py @@ -81,3 +81,7 @@ class InvalidAngle(Exception): class ShaderError(Exception): """GL Shader Error Exception.""" pass + +class FeatureError(Exception): + """Wrong Feature Type Error Exception.""" + pass |