diff --git a/io_mesh_atomic/pdb_gui.py b/io_mesh_atomic/pdb_gui.py
index f77e2ef4be16bb8d01001ba8ce21103e7ad100e4..711053d74770827c40d2cec424d53fc6f915206d 100644
--- a/io_mesh_atomic/pdb_gui.py
+++ b/io_mesh_atomic/pdb_gui.py
@@ -203,8 +203,9 @@ class IMPORT_OT_pdb(Operator, ImportHelper):
 
 
     def execute(self, context):
-        # To be on the safe side, we switch to the 'OBJECT' mode.
-        bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
+        # Switch to 'OBJECT' mode when in 'EDIT' mode.
+        if bpy.context.mode == 'EDIT_MESH':
+            bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
 
         # This is in order to solve this strange 'relative path' thing.
         filepath_pdb = bpy.path.abspath(self.filepath)
diff --git a/io_mesh_atomic/xyz_gui.py b/io_mesh_atomic/xyz_gui.py
index 18df006348ac5e6e848e4bed14367b4e466b915e..e465c4c21c51efb46e67f0ddd0fbec5a3a3c42ae 100644
--- a/io_mesh_atomic/xyz_gui.py
+++ b/io_mesh_atomic/xyz_gui.py
@@ -153,8 +153,9 @@ class IMPORT_OT_xyz(Operator, ImportHelper):
         col.prop(self, "images_per_key")
 
     def execute(self, context):
-        # To be on the safe side, we switch to the 'OBJECT' mode.
-        bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
+        # Switch to 'OBJECT' mode when in 'EDIT' mode.
+        if bpy.context.mode == 'EDIT_MESH':
+            bpy.ops.object.mode_set(mode='OBJECT', toggle=False)
 
         del ALL_FRAMES[:]
         del ELEMENTS[:]