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 <[email protected]>
This commit is contained in:
tetektoza
2025-05-05 17:58:54 +02:00
committed by GitHub
co-authored by Yorik van Havre
parent 57da6ac140
commit 7f6b3dcf70
2 changed files with 4 additions and 5 deletions
+2 -4
View File
@@ -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())
@@ -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