[Bf-extensions-cvs] [90b46441] blender-v2.82-release: PDT: Various improvements to help avoid user error

Alan Odom noreply at git.blender.org
Wed Feb 5 13:43:21 CET 2020


Commit: 90b46441d5e56777b871fdddcae4392379687b1d
Author: Alan Odom
Date:   Wed Feb 5 12:06:08 2020 +0000
Branches: blender-v2.82-release
https://developer.blender.org/rBA90b46441d5e56777b871fdddcae4392379687b1d

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.

===================================================================

M	precision_drawing_tools/pdt_command.py
M	precision_drawing_tools/pdt_command_functions.py
M	precision_drawing_tools/pdt_exception.py

===================================================================

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



More information about the Bf-extensions-cvs mailing list