From 6ac0cb75889b4909647392d41ec53a8740f43359 Mon Sep 17 00:00:00 2001 From: sliptonic Date: Tue, 10 Sep 2024 10:23:13 -0500 Subject: [PATCH] set default directory for sanity (#15934) Respond correctly if user cancels Fixes #14796 Co-authored-by: Brad Collette --- src/Mod/CAM/Path/Main/Gui/SanityCmd.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Mod/CAM/Path/Main/Gui/SanityCmd.py b/src/Mod/CAM/Path/Main/Gui/SanityCmd.py index f5c79b9a14..b02defb403 100644 --- a/src/Mod/CAM/Path/Main/Gui/SanityCmd.py +++ b/src/Mod/CAM/Path/Main/Gui/SanityCmd.py @@ -65,13 +65,21 @@ class CommandCAMSanity: # Ask the user for a filename to save the report to + defaultDir = os.path.split(FreeCAD.ActiveDocument.getFileName())[0] + + if defaultDir == "": + defaultDir = os.path.expanduser("~") + file_location = QFileDialog.getSaveFileName( None, translate("Path", "Save Sanity Check Report"), - os.path.expanduser("~"), + defaultDir, "HTML files (*.html)", )[0] + if file_location == "": + return + sanity_checker = Sanity.CAMSanity(obj, file_location) html = sanity_checker.get_output_report()