From f0efdc08a115dfe79390b7bfcfa69513a565bf7c Mon Sep 17 00:00:00 2001 From: DeepSOIC Date: Sat, 31 Oct 2015 22:57:43 +0300 Subject: [PATCH] Add option to cancel creation of feature in warning message --- latticeExecuter.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/latticeExecuter.py b/latticeExecuter.py index c2c5cdb..52efc8a 100644 --- a/latticeExecuter.py +++ b/latticeExecuter.py @@ -36,6 +36,9 @@ def executeFeature(obj): try: obj.Proxy.execute(obj) obj.purgeTouched() + except CancelError: + FreeCAD.ActiveDocument.abortTransaction() + raise except Exception as err: mb = QtGui.QMessageBox() mb.setIcon(mb.Icon.Warning) @@ -58,9 +61,19 @@ def warning(obj,message): mb.setIcon(mb.Icon.Warning) mb.setText(u"Warning: \n" + message) mb.setWindowTitle("Warning") + btnAbort = mb.addButton(QtGui.QMessageBox.StandardButton.Abort) + btnOK = mb.addButton("Continue",QtGui.QMessageBox.ButtonRole.ActionRole) + mb.setDefaultButton(btnOK) mb.exec_() + if mb.clickedButton() is btnAbort: + raise CancelError() + else: if obj is not None: FreeCAD.Console.PrintWarning(obj.Name + ": " + message) else: FreeCAD.Console.PrintWarning(message) + +class CancelError(Exception): + def __init__(self): + self.message = "Canceled by user" \ No newline at end of file