Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Odom <clockmender@icloud.com>2020-02-03 18:58:55 +0300
committerRune Morling <ermo.blender.org@spammesenseless.net>2020-02-04 04:13:28 +0300
commit6837f76f3538760c5f5279c833b8ad5a56335402 (patch)
tree793152e5482d0727c276e626a332452057b1797c /precision_drawing_tools
parentb82a685747e37f1af8e2d6a44691141e2a5e870e (diff)
PDT: Fix Cursor Placement with new empty file
Diffstat (limited to 'precision_drawing_tools')
-rw-r--r--precision_drawing_tools/pdt_command.py43
1 files changed, 21 insertions, 22 deletions
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":