diff options
Diffstat (limited to 'precision_drawing_tools')
-rw-r--r-- | precision_drawing_tools/pdt_library.py | 20 | ||||
-rw-r--r-- | precision_drawing_tools/pdt_msg_strings.py | 1 |
2 files changed, 16 insertions, 5 deletions
diff --git a/precision_drawing_tools/pdt_library.py b/precision_drawing_tools/pdt_library.py index c2565470..a0b1a6be 100644 --- a/precision_drawing_tools/pdt_library.py +++ b/precision_drawing_tools/pdt_library.py @@ -26,7 +26,7 @@ from bpy.types import Operator from mathutils import Vector from pathlib import Path from .pdt_functions import debug, oops -from .pdt_msg_strings import PDT_ERR_NO_LIBRARY +from .pdt_msg_strings import PDT_ERR_NO_LIBRARY, PDT_ERR_OBJECTMODE class PDT_OT_LibShow(Operator): @@ -81,14 +81,19 @@ class PDT_OT_Append(Operator): scene = context.scene pg = scene.pdt_pg + obj = context.view_layer.objects.active + if obj is not None: + if obj.mode != "OBJECT": + error_message = PDT_ERR_OBJECTMODE + self.report({"ERROR"}, error_message) + return {"FINISHED"} + obj_names = [o.name for o in context.view_layer.objects].copy() file_path = context.preferences.addons[__package__].preferences.pdt_library_path path = Path(file_path) if path.is_file() and ".blend" in str(path): if pg.lib_mode == "OBJECTS": - # Force object Mode - bpy.ops.object.mode_set(mode="OBJECT") bpy.ops.wm.append( filepath=str(path), directory=str(path) + "/Object", @@ -158,12 +163,17 @@ class PDT_OT_Link(Operator): scene = context.scene pg = scene.pdt_pg + obj = context.view_layer.objects.active + if obj is not None: + if obj.mode != "OBJECT": + error_message = PDT_ERR_OBJECTMODE + self.report({"ERROR"}, error_message) + return {"FINISHED"} + file_path = context.preferences.addons[__package__].preferences.pdt_library_path path = Path(file_path) if path.is_file() and ".blend" in str(path): if pg.lib_mode == "OBJECTS": - # Force object Mode - bpy.ops.object.mode_set(mode="OBJECT") bpy.ops.wm.link( filepath=str(path), directory=str(path) + "/Object", diff --git a/precision_drawing_tools/pdt_msg_strings.py b/precision_drawing_tools/pdt_msg_strings.py index 0c586200..8c7b9db2 100644 --- a/precision_drawing_tools/pdt_msg_strings.py +++ b/precision_drawing_tools/pdt_msg_strings.py @@ -84,6 +84,7 @@ PDT_LAB_PIVOTLOCH = "Location" # Error Message # PDT_ERR_NO_ACT_OBJ = "No Active Object - Please Select an Object" +PDT_ERR_OBJECTMODE = "Library Append/Link Tools Work Only in Object Mode" PDT_OBJ_MODE_ERROR = "Only Mesh Object in Edit or Object Mode Supported" PDT_ERR_NO_ACT_VERT = "No Active Vertex - Select One Vertex Individually" PDT_ERR_NO_SEL_GEOM = "No Geometry/Objects Selected" |