set default directory for sanity (#15934)

Respond correctly if user cancels  Fixes #14796

Co-authored-by: Brad Collette <bradcollette@pop-os.localdomain>
This commit is contained in:
sliptonic
2024-09-10 10:23:13 -05:00
committed by GitHub
parent 3503d677a9
commit 6ac0cb7588

View File

@@ -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()