[Bf-extensions-cvs] [6837f76f] blender-v2.82-release: PDT: Fix Cursor Placement with new empty file

Alan Odom noreply at git.blender.org
Tue Feb 4 02:15:03 CET 2020


Commit: 6837f76f3538760c5f5279c833b8ad5a56335402
Author: Alan Odom
Date:   Mon Feb 3 15:58:55 2020 +0000
Branches: blender-v2.82-release
https://developer.blender.org/rBA6837f76f3538760c5f5279c833b8ad5a56335402

PDT: Fix Cursor Placement with new empty file

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

M	precision_drawing_tools/pdt_command.py

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

diff --git a/precision_drawing_tools/pdt_command.py b/precision_drawing_tools/pdt_command.py
index 77550957..ad0f3528 100644
--- a/precision_drawing_tools/pdt_command.py
+++ b/precision_drawing_tools/pdt_command.py
@@ -25,6 +25,7 @@ import bpy
 import bmesh
 import math
 from bpy.types import Operator
+from mathutils import Vector
 from .pdt_functions import (
     debug,
     intersection,
@@ -419,7 +420,7 @@ def command_parse(context):
     operation = command[0].upper()
     mode = command[1].lower()
     values = command[2:].split(",")
-    mode_s = pg.select
+    mode_sel = pg.select
     obj = context.view_layer.objects.active
     ind = 0
     for v in values:
@@ -432,26 +433,22 @@ def command_parse(context):
     # Apply System Rounding
     decimal_places = context.preferences.addons[__package__].preferences.pdt_input_round
     values_out = [str(round(float(v), decimal_places)) for v in values]
-
-    bm, good = obj_check(obj, scene, operation)
-    if good:
-        obj_loc = obj.matrix_world.decompose()[0]
-    else:
-        obj_loc = None
-
-    if mode_s == 'SEL' and bm is not None and mode not in {"a"}:
-        if len(bm.select_history) == 0:
-            verts = [v for v in bm.verts if v.select]
-            if len(verts) == 0:
-                pg.error = PDT_ERR_NO_SEL_GEOM
-                context.window_manager.popup_menu(oops, title="Error", icon="ERROR")
-                raise PDT_SelectionError
-        else:
-            verts = bm.select_history
-    elif operation == "G" and mode == "a":
-        verts = [v for v in bm.verts if v.select]
-    else:
-        verts = []
+    bm = "None"
+    obj_loc = Vector((0,0,0))
+    verts = []
+
+    if mode_sel == 'SEL' and mode not in {"a"}:
+        bm, good = obj_check(obj, scene, operation)
+        if good and obj.mode == 'EDIT':
+            obj_loc = obj.matrix_world.decompose()[0]
+            if len(bm.select_history) == 0 or operation == "G":
+                verts = [v for v in bm.verts if v.select]
+                if len(verts) == 0:
+                    pg.error = PDT_ERR_NO_SEL_GEOM
+                    context.window_manager.popup_menu(oops, title="Error", icon="ERROR")
+                    raise PDT_SelectionError
+            else:
+                verts = bm.select_history
 
     debug(f"command: {operation}{mode}{values_out}")
     debug(f"obj: {obj}, bm: {bm}, obj_loc: {obj_loc}")
@@ -497,7 +494,9 @@ def move_cursor_pivot(context, pg, operation, mode, obj, verts, values):
 
     scene = context.scene
     mode_sel = pg.select
-    obj_loc = obj.matrix_world.decompose()[0]
+    obj_loc = Vector((0,0,0))
+    if obj is not None:
+        obj_loc = obj.matrix_world.decompose()[0]
 
     if mode == "a":
         if operation == "C":



More information about the Bf-extensions-cvs mailing list