| | |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| |
|
| | """ |
| | This file has the GUI command for checking and catching common errors in FreeCAD |
| | CAM projects. |
| | """ |
| |
|
| | from Path.Main.Sanity import Sanity |
| | from PySide.QtCore import QT_TRANSLATE_NOOP |
| | from PySide.QtGui import QFileDialog |
| | import FreeCAD |
| | import FreeCADGui |
| | import Path |
| | import Path.Log |
| | import os |
| | import webbrowser |
| |
|
| | translate = FreeCAD.Qt.translate |
| |
|
| | if False: |
| | Path.Log.setLevel(Path.Log.Level.DEBUG, Path.Log.thisModule()) |
| | Path.Log.trackModule(Path.Log.thisModule()) |
| | else: |
| | Path.Log.setLevel(Path.Log.Level.INFO, Path.Log.thisModule()) |
| |
|
| |
|
| | class CommandCAMSanity: |
| | def GetResources(self): |
| | return { |
| | "Pixmap": "CAM_Sanity", |
| | "MenuText": QT_TRANSLATE_NOOP("CAM_Sanity", "Sanity Check"), |
| | "Accel": "P, S", |
| | "ToolTip": QT_TRANSLATE_NOOP("CAM_Sanity", "Checks the CAM job for common errors"), |
| | } |
| |
|
| | def IsActive(self): |
| | selection = FreeCADGui.Selection.getSelectionEx() |
| | if len(selection) == 0: |
| | return False |
| | obj = selection[0].Object |
| | return isinstance(obj.Proxy, Path.Main.Job.ObjectJob) |
| |
|
| | def Activated(self): |
| | FreeCADGui.addIconPath(":/icons") |
| | obj = FreeCADGui.Selection.getSelectionEx()[0].Object |
| |
|
| | |
| |
|
| | 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"), |
| | defaultDir, |
| | "HTML files (*.html)", |
| | )[0] |
| |
|
| | if file_location == "": |
| | return |
| |
|
| | sanity_checker = Sanity.CAMSanity(obj, file_location) |
| | html = sanity_checker.get_output_report() |
| |
|
| | if html is None: |
| | Path.Log.error("Sanity check failed. No report generated.") |
| | return |
| |
|
| | with open(file_location, "w") as fp: |
| | fp.write(html) |
| |
|
| | FreeCAD.Console.PrintMessage("Sanity check report written to: {}\n".format(file_location)) |
| |
|
| | webbrowser.open_new_tab(file_location) |
| |
|
| |
|
| | if FreeCAD.GuiUp: |
| | |
| | FreeCADGui.addCommand("CAM_Sanity", CommandCAMSanity()) |
| |
|