From 253c343d736e11d473cfb4f30dfe0af055a54af7 Mon Sep 17 00:00:00 2001 From: Roy-043 Date: Fri, 2 Feb 2024 12:18:14 +0100 Subject: [PATCH 1/2] Draft: Draft_Arc_3Points minor consistency update --- src/Mod/Draft/draftguitools/gui_arcs.py | 33 +++++++++++---------- src/Mod/Draft/draftmake/make_arc_3points.py | 3 -- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/src/Mod/Draft/draftguitools/gui_arcs.py b/src/Mod/Draft/draftguitools/gui_arcs.py index 92d5ff373b..77b3088c53 100644 --- a/src/Mod/Draft/draftguitools/gui_arcs.py +++ b/src/Mod/Draft/draftguitools/gui_arcs.py @@ -100,7 +100,6 @@ class Arc(gui_base_original.Creator): if self.ui: self.linetrack.finalize() self.arctrack.finalize() - self.doc.recompute() if cont or (cont is None and self.ui and self.ui.continueMode): self.Activated() @@ -468,12 +467,9 @@ class Arc(gui_base_original.Creator): Gui.addCommand('Draft_Arc', Arc()) -class Arc_3Points(gui_base.GuiCommandSimplest): +class Arc_3Points(gui_base.GuiCommandBase): """GuiCommand for the Draft_Arc_3Points tool.""" - def __init__(self): - super().__init__(name="Arc by 3 points") - def GetResources(self): """Set icon, menu and tooltip.""" return {'Pixmap': "Draft_Arc_3Points", @@ -483,7 +479,10 @@ class Arc_3Points(gui_base.GuiCommandSimplest): def Activated(self): """Execute when the command is called.""" - super().Activated() + if App.activeDraftCommand: + App.activeDraftCommand.finish() + App.activeDraftCommand = self + self.featureName = "Arc_3Points" # Reset the values self.points = [] @@ -550,15 +549,16 @@ class Arc_3Points(gui_base.GuiCommandSimplest): # If three points were already picked in the 3D view # proceed with creating the final object. # Draw a simple `Part::Feature` if the parameter is `True`. - if params.get_param("UsePartPrimitives"): - Draft.make_arc_3points([self.points[0], - self.points[1], - self.points[2]], primitive=True) - else: - Draft.make_arc_3points([self.points[0], - self.points[1], - self.points[2]], primitive=False) - + Gui.addModule("Draft") + _cmd = "Draft.make_arc_3points([" + _cmd += "FreeCAD." + str(self.points[0]) + _cmd += ", FreeCAD." + str(self.points[1]) + _cmd += ", FreeCAD." + str(self.points[2]) + _cmd += "], primitive=" + str(params.get_param("UsePartPrimitives")) + ")" + _cmd_list = ["circle = " + _cmd, + "Draft.autogroup(circle)", + "FreeCAD.ActiveDocument.recompute()"] + self.commit(translate("draft", "Create Arc by 3 points"), _cmd_list) self.finish(cont=None) def drawArc(self, point, info): @@ -590,8 +590,9 @@ class Arc_3Points(gui_base.GuiCommandSimplest): Restart (continue) the command if `True`, or if `None` and `ui.continueMode` is `True`. """ + App.activeDraftCommand = None self.tracker.finalize() - self.doc.recompute() + super().finish() if cont or (cont is None and Gui.Snapper.ui and Gui.Snapper.ui.continueMode): self.Activated() diff --git a/src/Mod/Draft/draftmake/make_arc_3points.py b/src/Mod/Draft/draftmake/make_arc_3points.py index c21fc36b11..006b683819 100644 --- a/src/Mod/Draft/draftmake/make_arc_3points.py +++ b/src/Mod/Draft/draftmake/make_arc_3points.py @@ -183,9 +183,6 @@ def make_arc_3points(points, placement=None, face=False, startangle=start, endangle=end, support=support) - if App.GuiUp: - gui_utils.autogroup(obj) - original_placement = obj.Placement if placement and not support: From 834aff05a908de3a9c64992190adfc1e79f16213 Mon Sep 17 00:00:00 2001 From: Roy-043 Date: Fri, 2 Feb 2024 15:17:13 +0100 Subject: [PATCH 2/2] minor edit --- src/Mod/Draft/draftguitools/gui_arcs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Draft/draftguitools/gui_arcs.py b/src/Mod/Draft/draftguitools/gui_arcs.py index 77b3088c53..73b0450e24 100644 --- a/src/Mod/Draft/draftguitools/gui_arcs.py +++ b/src/Mod/Draft/draftguitools/gui_arcs.py @@ -591,8 +591,8 @@ class Arc_3Points(gui_base.GuiCommandBase): `ui.continueMode` is `True`. """ App.activeDraftCommand = None - self.tracker.finalize() super().finish() + self.tracker.finalize() if cont or (cont is None and Gui.Snapper.ui and Gui.Snapper.ui.continueMode): self.Activated()