From 7f6b3dcf70d5e6341fbe250666166b633434dae0 Mon Sep 17 00:00:00 2001 From: tetektoza Date: Mon, 5 May 2025 17:58:54 +0200 Subject: [PATCH] Draft: Preserve direction vector upon Continue Mode for Dimension (#20974) So, currently, if we use Vertical/Horizontal Dimension which is constrained in one direction vector, upon `Continue`, the direction vector is not being preserved. The cause of that is that everytime we recall the command in Continue Mode, we also call base class' `Activated` method, which in turn calls `finish()` if we have already initialized an active Draft command. This doesn't happen during first usage of the command, because this variable is not yet populated, but upon second (and next) runs it is. In turn, this causes to call `finish()`, and clean up the direction vector. So, in essence, we are specifying the vector and cleaning it every "Continue" run. So, as a solution, just move the direction vector as an argument to populate super class with it, and do that after super class' `Activated()` call, so it won't get cleaned up in `finish()`. Co-authored-by: Yorik van Havre --- src/Mod/BIM/bimcommands/BimDimensions.py | 6 ++---- src/Mod/Draft/draftguitools/gui_dimensions.py | 3 ++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Mod/BIM/bimcommands/BimDimensions.py b/src/Mod/BIM/bimcommands/BimDimensions.py index 1b1fed782f..569343519e 100644 --- a/src/Mod/BIM/bimcommands/BimDimensions.py +++ b/src/Mod/BIM/bimcommands/BimDimensions.py @@ -66,11 +66,10 @@ class BIM_DimensionHorizontal(gui_dimensions.Dimension): } def Activated(self): - import WorkingPlane self.dir = WorkingPlane.get_working_plane().u - super().Activated() + super().Activated(dir_vec=self.dir) class BIM_DimensionVertical(gui_dimensions.Dimension): @@ -91,11 +90,10 @@ class BIM_DimensionVertical(gui_dimensions.Dimension): } def Activated(self): - import WorkingPlane self.dir = WorkingPlane.get_working_plane().v - super().Activated() + super().Activated(dir_vec=self.dir) FreeCADGui.addCommand("BIM_DimensionVertical", BIM_DimensionVertical()) diff --git a/src/Mod/Draft/draftguitools/gui_dimensions.py b/src/Mod/Draft/draftguitools/gui_dimensions.py index 778d46df04..e32d55ae5b 100644 --- a/src/Mod/Draft/draftguitools/gui_dimensions.py +++ b/src/Mod/Draft/draftguitools/gui_dimensions.py @@ -87,7 +87,7 @@ class Dimension(gui_base_original.Creator): 'MenuText': QT_TRANSLATE_NOOP("Draft_Dimension", "Dimension"), 'ToolTip': QT_TRANSLATE_NOOP("Draft_Dimension", "Creates a dimension.\n\n- Pick three points to create a simple linear dimension.\n- Select a straight line to create a linear dimension linked to that line.\n- Select an arc or circle to create a radius or diameter dimension linked to that arc.\n- Select two straight lines to create an angular dimension between them.\nCTRL to snap, SHIFT to constrain, ALT to select an edge or arc.\n\nYou may select a single line or single circular arc before launching this command\nto create the corresponding linked dimension.\nYou may also select an 'App::MeasureDistance' object before launching this command\nto turn it into a 'Draft Dimension' object.")} - def Activated(self): + def Activated(self, dir_vec=None): """Execute when the command is called.""" if self.chain and not self.contMode: self.finish() @@ -103,6 +103,7 @@ class Dimension(gui_base_original.Creator): self.dimtrack = trackers.dimTracker() self.arctrack = trackers.arcTracker() self.link = None + self.dir = dir_vec self.edges = [] self.angles = [] self.angledata = None