[Bf-extensions-cvs] [2eb5ee12] blender-v2.82-release: PDT: Fix Command Line selection-related bug
Alan Odom
noreply at git.blender.org
Tue Jan 14 22:32:15 CET 2020
Commit: 2eb5ee12cef8cc8500042c46905c64f4d12575cf
Author: Alan Odom
Date: Mon Jan 13 16:34:56 2020 +0000
Branches: blender-v2.82-release
https://developer.blender.org/rBA2eb5ee12cef8cc8500042c46905c64f4d12575cf
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.
===================================================================
M precision_drawing_tools/pdt_command.py
===================================================================
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()
More information about the Bf-extensions-cvs
mailing list